File: /home/zwafgyp/lacalita/wp-content/plugins/rey-core/assets/js/general/c-modal.js
!function(t){var e={};function o(i){if(e[i])return e[i].exports;var a=e[i]={i:i,l:!1,exports:{}};return t[i].call(a.exports,a,a.exports,o),a.l=!0,a.exports}o.m=t,o.c=e,o.d=function(t,e,i){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(o.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)o.d(i,a,function(e){return t[e]}.bind(null,a));return i},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=1)}([function(t,e,o){"use strict";function i(){return(i=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(t[i]=o[i])}return t}).apply(this,arguments)}function a(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}o.d(e,"a",(function(){return n}));var n=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);this.config=i({backscroll:!0,linkAttributeName:"data-reymodal",extraAttributes:'[data-rey-inline-modal][href^="http"]:not([href="#"])',closeOnOverlay:!0,closeOnEsc:!0,closeOnButton:!0,waitTransitions:!1,catchFocus:!0,fixedSelectors:"*[data-reyfixed]",beforeOpen:function(){},afterOpen:function(){},afterClose:function(){}},e),this.config.linkAttributeName&&this.init(),this._closeAfterTransition=this._closeAfterTransition.bind(this),"undefined"!=typeof rey&&(rey.___.modal_scripts_loaded=!0)}var e,o,n;return e=t,(o=[{key:"init",value:function(){this.isOpened=!1,this.openedWindow=!1,this.starter=!1,this._nextWindows=!1,this._scrollPosition=0,this._reopenTrigger=!1,this._overlayChecker=!1,this._isMoved=!1,this._exists=!1,this._focusElements=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'],this._modalBlock=!1,this._prefix="rmodal-",this.modalData={},this._modalDataExtra=!1;var t=document.querySelector(".reymodal__shadow");return t?this.shadow=t:(this.shadow=document.createElement("div"),this.shadow.classList.add("reymodal__shadow"),this.shadow.style.display="none",document.body.appendChild(this.shadow)),this.eventsFeeler(),this}},{key:"eventsFeeler",value:function(){var t=this;document.addEventListener("click",(function(e){var o=e.target.closest(`[${t.config.linkAttributeName}], ${t.config.extraAttributes}`);if(t._isMoved||!o)(e.target.closest('.rey-modal-section a[href*="#"]:not([href$="#"])')||t.config.closeOnButton&&e.target.closest("[data-reyclose]"))&&t.close();else{e.preventDefault(),t.starter=o;var i=t.starter.getAttribute(t.config.linkAttributeName);if(rey.validation.isValidURL(i)||(t.modalData=JSON.parse(i||"{}")),!Object.keys(t.modalData).length){var a=i||t.starter.getAttribute("data-rey-inline-modal")||t.starter.getAttribute("href")||t.starter.getAttribute("data-href");if(!a)return;if(-1!==a.indexOf("youtube.com")?(t.modalData.type="iframe",t.modalData.src=a,t.modalData.videoService="youtube"):-1!==a.indexOf("youtu.be")?(t.modalData.type="iframe",t.modalData.src=a.replace("youtu.be/","youtube.com/watch?v="),t.modalData.videoService="youtube"):-1!==a.indexOf("vimeo.com")&&(t.modalData.type="iframe",t.modalData.src=a,t.modalData.videoService="vimeo"),!Object.keys(t.modalData).length)return;t.modalData.id=t.urlToID(a),t.modalData.width=750}t.open()}})),this.config.closeOnOverlay&&(document.addEventListener("mousedown",(function(e){!t._isMoved&&e.target instanceof Element&&!e.target.classList.contains("reymodal__wrap")||(t._overlayChecker=!0)})),document.addEventListener("mouseup",(function(e){if(!t._isMoved&&e.target instanceof Element&&t._overlayChecker&&e.target.classList.contains("reymodal__wrap"))return e.preventDefault(),t._overlayChecker=!t._overlayChecker,void t.close();t._overlayChecker=!1}))),window.addEventListener("keydown",(function(e){if(!t._isMoved&&t.config.closeOnEsc&&27===e.which&&t.isOpened)return e.preventDefault(),void t.close();!t._isMoved&&t.config.catchFocus&&9===e.which&&t.isOpened&&t.focusCatcher(e)}))}},{key:"getModalData",value:function(){return i({id:(new Date).getTime(),type:"selector",src:"",content:"",caption:"",replacements:{},width:"",wrapperClass:"",closeColor:"",closePosition:"",autoplay:!0,ratio:"",videoFormat:""},this.modalData)}},{key:"createMarkup",value:function(){this.modalData=this.getModalData(),this.modalData.id=this._prefix+this.modalData.id;var t=document.getElementById(this.modalData.id);if(t)return this._exists=!0,void(this._nextWindows=t);if(this.createContent(),this.modalData.caption){this.$caption=document.createElement("div"),this.$caption.classList.add("reymodal__caption");let t=document.createTextNode(this.modalData.caption);this.$caption.appendChild(t)}this.$closeButton=document.createElement("button"),this.$closeButton.classList.add("reymodal__close"),this.$closeButton.setAttribute("data-reyclose",""),this.$closeButton.setAttribute("aria-label","Close");var e=this.modalData.closePosition||this._modalDataExtra&&this._modalDataExtra.closePosition;e&&this.$closeButton.classList.add("--p-"+e),this._modalDataExtra&&this._modalDataExtra.closeColor&&this.$closeButton.style.setProperty("color",this._modalDataExtra.closeColor),this.$window=document.createElement("div"),this.$window.classList.add("reymodal__window"),this.$window.setAttribute("aria-modal","true"),this.$window.setAttribute("role","dialog"),this.modalData.width&&this.$window.style.setProperty("max-width",this.modalData.width+"px"),this.$content&&this.$window.appendChild(this.$content),this._modalDataExtra&&this._modalDataExtra.closeParent?this.$window.querySelector(this._modalDataExtra.closeParent).appendChild(this.$closeButton):this.$window.appendChild(this.$closeButton),this.modalData.caption&&this.$window.appendChild(this.$caption),this.$innerWrap=document.createElement("div"),this.$innerWrap.classList.add("reymodal__wrap"),this.$innerWrap.appendChild(this.$window),this.$wrapper=document.createElement("div"),this.$wrapper.classList.add("reymodal","--type-"+this.modalData.type),this.modalData.wrapperClass&&this.$wrapper.classList.add(this.modalData.wrapperClass),this._modalDataExtra&&this._modalDataExtra.wrapperClass&&this.$wrapper.classList.add(this._modalDataExtra.wrapperClass),this.$wrapper.setAttribute("aria-hidden","true"),this.$wrapper.setAttribute("id",this.modalData.id),this.$wrapper.appendChild(this.$innerWrap),this._nextWindows=document.body.appendChild(this.$wrapper)}},{key:"createContent",value:function(){if("image"===this.modalData.type)this.$content=document.createElement("img"),this.$content.classList.add("reymodal__image"),this.$content.setAttribute("src",this.modalData.src);else if("video"===this.modalData.type)this.$contentVideo=document.createElement("video"),this.$contentVideo.setAttribute("src",this.modalData.src),this.$contentVideo.setAttribute("preload","auto"),this.$contentVideo.setAttribute("controls",""),this.$contentVideo.setAttribute("poster",""),this.$content=document.createElement("div"),this.$content.classList.add("reymodal__video"),this.$content.setAttribute("data-ratio",this.modalData.videoFormat),this.$content.appendChild(this.$contentVideo);else if("iframe"===this.modalData.type){var t=this.getIframeSrc();t&&(this.$contentIframe=document.createElement("iframe"),this.$contentIframe.setAttribute("src",t),this.$contentIframe.setAttribute("frameborder","0"),this.$contentIframe.setAttribute("allow","accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"),this.$contentIframe.setAttribute("allowfullscreen",""),this.$content=document.createElement("div"),this.$content.classList.add("reymodal__video"),this.$content.setAttribute("data-ratio",this.modalData.videoFormat),this.$content.appendChild(this.$contentIframe))}else if("selector"===this.modalData.type){var e;if("string"==typeof this.modalData.content?e=document.body.querySelector(this.modalData.content):"object"==typeof this.modalData.content&&this.modalData.content instanceof HTMLElement?e=this.modalData.content:"object"==typeof this.modalData.content&&Object.keys(this.modalData.content).length&&(e=this.modalData.content[0]),e){this.$content=e;var o=JSON.parse(this.$content.getAttribute("data-modal-extra")||"{}");Object.keys(o).length&&(this._modalDataExtra=o);var i=this.$content.getAttribute("data-elementor-class"),a=this;i&&(i.split(" ").forEach((t=>{a.$content.classList.add(t)})),this.$content.removeAttribute("data-elementor-class"))}}else"html"===this.modalData.type&&(this.$content=document.createElement("div"),this.$content.classList.add("reymodal__html"),this.$content.innerHTML=this.modalData.content);this.modalData.ratio&&this.$content&&this.$content.style.setProperty("--custom-video-ratio",this.modalData.ratio+"%")}},{key:"getIframeSrc",value:function(){var t={youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%%sep%autoplay=1&rel=0&enablejsapi=1&showinfo=0&playsinline=1&mute=1",time:"&t="},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1&muted=1",time:"#t="},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}},e=this.modalData.src;return Object.keys(t).forEach((function(o){var i=t[o];if(e.indexOf(i.index)>-1&&("youtube.com"!==i.index||-1===e.indexOf("embed/"))){var a="?";return i.id&&("string"==typeof i.id&&(e=e.substr(e.lastIndexOf(i.id)+i.id.length,e.length)),i.time&&-1!==e.lastIndexOf(i.time)&&(e=(e=e.replace("&start=","?start=")).replace("&t=","?start="),a="&")),e=i.src.replace("%sep%",a).replace("%id%",e),!1}})),e}},{key:"open",value:function(t){if(t&&(this.modalData=t),this.createMarkup(),this._nextWindows){if(this.isOpened)return this._reopenTrigger=!0,void this.close();this.openedWindow=this._nextWindows,this._modalBlock=this.openedWindow.querySelector(".reymodal__window"),this.$content&&this.$content.classList.remove("--hidden"),this.config.beforeOpen(this),this._runReplacements(),this._bodyScrollControl(),this.shadow.style.display="",this.shadow.classList.add("reymodal__shadow--show"),this.openedWindow.classList.add("reymodal--active"),this.openedWindow.setAttribute("aria-hidden","false"),this.modalData.autoplay&&this.$contentVideo&&(this.$contentVideo.autoplay=!0,this.$contentVideo.load()),this.config.catchFocus&&this.focusControl(),this.config.afterOpen(this),this.isOpened=!0}else console.log("Warning: ReyModal selector is not found")}},{key:"close",value:function(){this._preventClose||this.isOpened&&(this.config.waitTransitions?(this.openedWindow.classList.add("reymodal--moved"),this._isMoved=!0,this.openedWindow.addEventListener("transitionend",this._closeAfterTransition),this.openedWindow.classList.remove("reymodal--active")):(this.openedWindow.classList.remove("reymodal--active"),this._closeAfterTransition()))}},{key:"setPreventClose",value:function(t){this._preventClose=t,this.$closeButton.style.display=!0===t?"none":"block"}},{key:"_runReplacements",value:function(){if(this.modalData.replacements&&"video"!==this.modalData.type&&"iframe"!==this.modalData.type&&!this._hasReplaced){var t=this.$content||this.openedWindow;if(t){for(var e in this.modalData.replacements){var o=this.modalData.replacements[e];if(0===e.indexOf("#")||0===e.indexOf(".")){var i=t.querySelector(e);i&&("INPUT"===i.tagName?i.setAttribute("value",o):i.innerHTML=o)}else t.innerHTML=t.innerHTML.replace(new RegExp(e,"g"),o)}this._hasReplaced=!0}}}},{key:"_closeAfterTransition",value:function(){this.openedWindow.classList.remove("reymodal--moved"),this.openedWindow.removeEventListener("transitionend",this._closeAfterTransition),this._isMoved=!1,this.shadow.classList.remove("reymodal__shadow--show"),this.openedWindow.setAttribute("aria-hidden","true"),this.config.catchFocus&&this.focusControl(),this._bodyScrollControl(),this.isOpened=!1,this.openedWindow.scrollTop=0,this.config.afterClose(this),this.stopVideos(),this._reopenTrigger&&(this._reopenTrigger=!1,this.open())}},{key:"stopVideos",value:function(){if(this.$contentVideo)this.$contentVideo.pause(),this.$contentVideo.currentTime=0;else if(this.$contentIframe){if(this.modalData.videoService&&"vimeo"===this.modalData.videoService)return void this.$contentIframe.contentWindow.postMessage('{"method":"pause"}',"*");this.$contentIframe.contentWindow.postMessage('{"event":"command","func":"stopVideo","args":""}',"*")}}},{key:"focusControl",value:function(){var t=this.openedWindow.querySelectorAll(this._focusElements);this.isOpened&&this.starter?this.starter.focus():t.length&&t[0].focus()}},{key:"focusCatcher",value:function(t){var e=this.openedWindow.querySelectorAll(this._focusElements),o=Array.prototype.slice.call(e);if(this.openedWindow.contains(document.activeElement)){var i=o.indexOf(document.activeElement);t.shiftKey&&0===i&&(o[o.length-1].focus(),t.preventDefault()),t.shiftKey||i!==o.length-1||(o[0].focus(),t.preventDefault())}else o[0].focus(),t.preventDefault()}},{key:"urlToID",value:function(t){var e="àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìıİłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;",o=new RegExp(e.split("").join("|"),"g");return t.toString().toLowerCase().replace(/\//g,"").replace(/\s+/g,"-").replace(o,(t=>"aaaaaaaaaacccddeeeeeeeegghiiiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------".charAt(e.indexOf(t)))).replace(/&/g,"-and-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"")}},{key:"_bodyScrollControl",value:function(){if(this.config.backscroll){if(!0===this.isOpened)return document.documentElement.classList.remove("reymodal__opened"),void document.body.classList.remove("--no-scroll");document.documentElement.classList.add("reymodal__opened"),document.body.classList.add("--no-scroll")}}}])&&a(e.prototype,o),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}()},function(t,e,o){"use strict";o.r(e),function(t){var e=o(0);o(3),o(4);t.ReyModal=e.a}.call(this,o(2))},function(t,e){var o;o=function(){return this}();try{o=o||new Function("return this")()}catch(t){"object"==typeof window&&(o=window)}t.exports=o},function(t,e){"undefined"!=typeof Element&&(Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(t){var e=this;do{if(e.matches(t))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null}))},function(t,e,o){}]);var myModals=new ReyModal({catchFocus:!1,closeOnEsc:!0,backscroll:!0});