!function(d){d(window).on("elementor/frontend/init",()=>{class e extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{container:".pp-image-gallery-container",gallery:".pp-image-gallery",justifiedGallery:".pp-image-gallery-justified",filterItems:".pp-gallery-filter"}}}getDefaultElements(){var e=this.getSettings("selectors");return{$container:this.$element.find(e.container),$gallery:this.$element.find(e.gallery),$justifiedGallery:this.$element.find(e.justifiedGallery),$filterItems:this.$element.find(e.filterItems)}}bindEvents(){var e=this.elements.$container.data("settings"),t=this.elements.$gallery;elementorFrontend.isEditMode()||("justified"!=e.layout&&this.initMasonryLayout(t),t.hasClass("pp-image-gallery-filter-enabled")&&this.initFilters(t,e),"yes"===e.pagination&&this.initLoadMore(t,e,[],[])),"yes"===e.tilt_enable&&this.initTilt(),"justified"===e.layout&&this.initjustifiedLayout(),this.initLightbox()}initMasonryLayout(n){var e=n.hasClass("pp-image-gallery-masonry")?"masonry":"fitRows",t=this.elements.$filterItems;let i="",a=(d(t).each(function(){""!==i&&i!==undefined||(i=d(this).attr("data-default"))}),{itemSelector:".pp-grid-item-wrap",layoutMode:e,percentPosition:!0,filter:i});this.elements.$container.imagesLoaded(function(){n.isotope(a),n.find(".pp-gallery-slide-image").on("load",function(){d(this).hasClass("lazyloaded")||setTimeout(function(){n.isotope("layout")},500)})}),elementorFrontend.elements.$window.on("elementor-pro/motion-fx/recalc",function(){n.isotope("layout")});["ppe-tabs-switched","ppe-toggle-switched","ppe-accordion-switched","ppe-popup-opened"].forEach(function(i){void 0!==i&&d(document).on(i,function(e,t){0<(t="ppe-popup-opened"==i?d(".pp-modal-popup-"+t):t).find(".pp-image-gallery").length&&setTimeout(function(){n.isotope("layout")},100)})})}initFilters(a,s){const l=this.getID(),o=this.getElementSettings("lightbox_library"),r=this;this.elements.$container.on("click",".pp-gallery-filter",function(){let e=d(this),t=e.attr("data-filter"),i=e.attr("data-gallery-index"),n=a.find(t);"*"===t&&(n=a.find(".pp-grid-item-wrap")),d(n).each(function(){var e=d(this).find(".pp-image-gallery-item-link");"fancybox"===o?e.attr("data-fancybox",i+"_"+l):e.attr("data-elementor-lightbox-slideshow",i+"_"+l)}),e.siblings().removeClass("pp-active"),e.addClass("pp-active"),"justified"===s.layout?r.initjustifiedLayout(t):a.isotope({filter:t})}),d(".pp-filters-dropdown").on("change",function(){let e=this.value,t=d(this).find(":selected").attr("data-gallery-index"),i=a.find(e);"*"===e&&(i=a.find(".pp-grid-item-wrap")),d(i).each(function(){var e=d(this).find(".pp-image-gallery-item-link");"fancybox"===o?e.attr("data-fancybox",t+"_"+l):e.attr("data-elementor-lightbox-slideshow",t+"_"+l)}),a.isotope({filter:e})}),this.hashChange(),d(window).on("hashchange",function(){this.hashChange()}.bind(this))}initjustifiedLayout(e){const t=this.elements.$container.data("settings"),i=this.elements.$justifiedGallery;let n={rowHeight:t.row_height,lastRow:t.last_row,selector:"div",waitThumbnailsLoad:!0,margins:t.image_spacing,border:0};e&&(n.filter=e),i.imagesLoaded(function(){i.justifiedGallery(n).on("jg.complete jg.resize",function(e){var t=d(this).data("jg.controller");0===t.rows&&"hide"===t.settings.lastRow&&(n.lastRow="justify",d(this).justifiedGallery(n))})}.bind(this))}initLoadMore(e,t,i,n){const a=this;e.find(".pp-grid-item-wrap").each(function(){n.push(d(this).data("item-id"))}),this.elements.$container.find(".pp-gallery-load-more").off("click").on("click",function(e){e.preventDefault(),d(this).addClass("disabled pp-loading"),0<i.length?a.renderGalleryItems(i,n):a.getAjaxPhotos(i,n,t)})}getAjaxPhotos(t,i,e){const n=this;e={action:"pp_gallery_get_images",pp_action:"pp_gallery_get_images",settings:e};d.ajax({type:"post",url:window.location.href.split("#").shift(),context:this,data:e,success:function(e){e.success&&((e=e.data.items)&&d(e).each(function(){d(this).hasClass("pp-grid-item-wrap")&&t.push(this)}),n.renderGalleryItems(t,i))},error:function(e,t){console.log(t)}})}renderGalleryItems(e,n){const a=this.elements.$container.data("settings"),s=this.elements.$gallery,l=(s.attr("id"),this.elements.$justifiedGallery),o=this;if(this.elements.$container.find(".pp-gallery-load-more").removeClass("disabled pp-loading"),0<e.length){let t=1,i=[];d(e).each(function(){var e=d(this).data("item-id");if(-1===d.inArray(e,n)){if(!(t<=parseInt(a.per_page,10)))return!1;n.push(e),i.push(this),t++}}),0<i.length&&(i=d(i)).imagesLoaded(function(){"justified"!=a.layout&&(s.isotope("insert",i),setTimeout(function(){s.isotope("layout")},500)),"justified"===a.layout&&0<l.length&&(s.append(i.fadeIn()),l.imagesLoaded(function(){}).done(function(e){setTimeout(function(){l.justifiedGallery("norewind")},200)})),"yes"===a.tilt_enable&&o.initTilt(),o.initLightbox()}),e.length===n.length&&this.elements.$container.find(".pp-gallery-pagination").hide()}}hashChange(){setTimeout(function(){location.hash&&0<d(location.hash).length&&d(location.hash).parent().hasClass("pp-gallery-filters")&&d(location.hash).trigger("click")},500)}initLightbox(){var e='.pp-grid-item-wrap .pp-image-gallery-item-link[data-fancybox="'+this.elements.$gallery.attr("id")+'"]',t=this.elements.$gallery.data("fancybox-settings");0<d(e).length&&d(e).fancybox(t)}initTilt(){var e=this.elements.$container.data("settings"),t=this.elements.$gallery;d(t).find(".pp-image-gallery-thumbnail-wrap").tilt({disableAxis:e.tilt_axis,maxTilt:e.tilt_amount,scale:e.tilt_scale,speed:e.tilt_speed,perspective:1e3})}}elementorFrontend.elementsHandler.attachHandler("pp-image-gallery",e)})}(jQuery);