// source --> https://diecastbyfariq.com/wp-content/themes/glozin/assets/js/woocommerce/product-catalog.min.js?ver=1.0.0 
(function(m){"use strict";var p=p||{};p.init=function(){p.$body=m(document.body),p.$window=m(window),p.$header=m("#site-header");this.shopHeaderMore();this.catalogFiltersHorizontal();this.changeCatalogElementsFiltered();this.catalogOrderBy();this.catalogView();this.loadMoreProducts();this.loadProductsbyViewAJAX();this.sidebarPanel()};p.shopHeaderMore=function(){m(".shop-header__description-inner").each(function(){var e=m(this);var t=e.outerHeight();e.data("defaultHeight",t);e.css({"max-height":t+"px"});if(e[0].scrollHeight>e[0].clientHeight){e.siblings(".shop-header__more-wrapper").removeClass("hidden")}});m(document.body).on("click",".shop-header__more",function(e){e.preventDefault();var t=m(this).data("settings"),o=m(this).closest(".shop-header__more-wrapper"),i=o.siblings(".shop-header__description-inner"),a=t.more,l=t.less;if(i.length===0){return}if(!i.data("defaultHeight")){i.data("defaultHeight",i.outerHeight())}var n=i.data("defaultHeight");if(o.hasClass("less")){o.removeClass("less");m(this).text(a);i.css({"max-height":n+"px"})}else{o.addClass("less");m(this).text(l);i.css("-webkit-line-clamp","inherit");i.css({"max-height":i[0].scrollHeight+"px"})}})};p.catalogFiltersHorizontal=function(){p.$body.on("click",".catalog-filters-horizontal .products-filter__filter .filter-name",function(e){e.preventDefault();var t=m(this).closest(".products-filter__filter");m(".products-filter__filter").not(t).removeClass("glozin-active");t.toggleClass("glozin-active");m(".gz-widget-heading").removeClass("glozin-active")}).on("click",".catalog-filters-horizontal .gz-widget-heading",function(e){e.preventDefault();var t=m(this);m(".gz-widget-heading").not(t).removeClass("glozin-active");t.toggleClass("glozin-active");m(".products-filter__filter").removeClass("glozin-active")}).on("keyup",function(e){if(e.keyCode===27){m(".products-filter__filter").removeClass("glozin-active");m(".gz-widget-heading").removeClass("glozin-active")}}).on("click",function(e){var t=m(e.target);if(t.closest(".products-filter__filter, .gz-widget-heading").length){return}m(".products-filter__filter").removeClass("glozin-active");m(".gz-widget-heading").removeClass("glozin-active")})};p.changeCatalogElementsFiltered=function(){p.$body.on("glozin_products_filter_before_send_request",function(e,t){m(".products-filter__filter").removeClass("glozin-active");m(".gz-widget-heading").removeClass("glozin-active");setTimeout(function(){m(".catalog-filters-sidebar .sidebar__button-close").trigger("click")},300);m("#glozin-shop-content").addClass("loading")});var o=p.$body.find("#page-header"),i=p.$body.find(".catalog-toolbar"),a=p.$body.find(".catalog-toolbar__active-filters"),l=m(".catalog-toolbar__filters-actived"),a=m(".catalog-toolbar__active-filters"),n=m(".catalog-filters-sidebar"),e=n.find(".products-filter__activated-items"),r='<a href="#" class="remove-filtered remove-filtered-all">'+l.data("clear-text")+"</a>";t();p.$body.on("glozin_products_filter_request_success",function(e,t){var o=m(t);s(o);d(o);p.scrollTopFilterAJAX()});function s(e){if(e.find("#page-header").length){o.replaceWith(e.find("#page-header"))}if(e.find(".catalog-toolbar__result-count").length){i.find(".catalog-toolbar__result-count").replaceWith(e.find(".catalog-toolbar__result-count"))}if(e.find(".catalog-toolbar__orderby-form").length){i.find(".catalog-toolbar__orderby-form").replaceWith(e.find(".catalog-toolbar__orderby-form").get(0));var t=i.find(".woocommerce-ordering option:selected").val();i.find(".catalog-toolbar__orderby-list a[data-id="+t+"]").addClass("selected")}}function t(){if(e.html()&&e.html().trim()){l.html("");l.removeClass("active");l.prepend(e.html()+r);l.addClass("active");a.addClass("actived");a.removeClass("hidden")}l.on("click",".remove-filtered:not(.remove-filtered-all)",function(e){var t=m(this).data("value");if(t!=="undefined"){n.find(".remove-filtered[data-value='"+t+"']").trigger("click")}m("#glozin-shop-content").addClass("loading");return false});l.on("click",".remove-filtered-all",function(e){e.preventDefault();m("#glozin-shop-content").addClass("loading");n.find(".products-filter__activated-heading .reset-button").trigger("click")});m(document.body).on("glozin_products_filter_reseted",function(){m("#site-content .woocommerce-notices-wrapper").fadeOut()})}function d(e){var t=e.filter(".catalog-filters-sidebar").find(".products-filter__activated-items"),o=e.find(".catalog-filters-sidebar .products-filter__activated-items");if(t.children().length>0){if(t.html()&&t.html().trim()){l.removeClass("hidden");l.html("");l.removeClass("active");l.prepend(t.html()+r);l.addClass("active");a.addClass("actived");a.removeClass("hidden")}}else if(o.children().length>0){if(o.html()&&o.html().trim()){l.removeClass("hidden");l.html("");l.removeClass("active");l.prepend(o.html()+r);l.addClass("active");a.addClass("actived");a.removeClass("hidden")}}else{if(l.hasClass("active")){l.html("");l.removeClass("active");a.removeClass("actived");a.addClass("hidden")}}}};p.scrollTopFilterAJAX=function(){var e=0;if(!m("#glozin-shop-content").length){return}if(p.$window.width()>1200){if(m("#wpadminbar").length){e+=m("#wpadminbar").outerHeight()}if(m(".site-header__desktop").hasClass("glozin-header-sticky")){if(m(".site-header__desktop").hasClass("header-sticky--both")){e+=m(".site-header__desktop").outerHeight()}else{e+=m(".site-header__desktop").find(".header-sticky").outerHeight()}}}else{if(m(".site-header__mobile").hasClass("glozin-header-mobile-sticky")){if(m(".site-header__mobile").hasClass("header-sticky--both")){e+=m(".site-header__mobile").outerHeight()}else{e+=m(".site-header__mobile").find(".header-mobile-sticky").outerHeight()}}}var t=m("#primary").hasClass("position-sticky-lg");if(t){m("#primary").removeClass("position-sticky-lg")}m("html,body").stop().animate({scrollTop:m("#primary").length?m("#primary").offset().top-e-30:m("#glozin-shop-content").offset().top-e-30},300,function(){if(t){m("#primary").addClass("position-sticky-lg")}});m("#glozin-shop-content").delay(500).queue(function(e){m(this).removeClass("loading");e()})};p.catalogView=function(){var s=m("#glozin-toolbar-view"),e=m("#glozin-shop-content").find("ul.products"),d=e.data("layout");p.$body.on("click",".gz-shop-view-item",function(e){e.preventDefault();var t=m(this),o=t.attr("href"),i=t.closest(".site-content").find("#glozin-shop-content").find("ul.products");t.siblings().removeClass("current");m(this).addClass("current");var a="grid",l=t.data("column"),n="",r="";switch(l){case 1:a="list";n="columns-1 product-card-layout-list";r="columns-3 columns-2 columns-4 product-card--"+d;i.removeClass(r).addClass(n);s.removeClass("view-grid").addClass("view-list");break;case 2:case 3:case 4:a="grid";r="columns-"+l+" product-card-layout-"+d;n="product-card-layout-list columns-1 columns-2 columns-3 columns-4";i.removeClass(n).addClass(r);s.removeClass("view-list").addClass("view-grid");break}document.cookie="catalog_view="+a+";domain="+window.location.host+";path=/";window.history.pushState(null,"",o)})};p.loadProductsbyViewAJAX=function(){var r=m("#glozin-toolbar-view"),s=m("#glozin-shop-content");p.$body.on("submit",".catalog-toolbar__orderby-form",function(e){e.preventDefault();var t=m(this),o=t.attr("action")||window.location.href.split("?")[0],i=o,a=o.indexOf("?")!==-1?"&":"?",l=t.find("input, select"),n={};n=l.filter(function(){return this.value!==""&&this.name!==""}).serializeObject();if(n.paged&&n.paged==="1"){delete n.paged}if(_.size(n)>0){i+=a+m.param(n,true)}d(i)});function d(n){s.addClass("loading");m(document.body).trigger("glozin_progress_bar_start");m.get(n,function(e){var t=m(e).find(".glozin-shop-content"),o=t.find("ul.products"),i=m(e).find(".woocommerce-pagination").html(),a=m(e).find(".glozin-toolbar-view").html();m(document.body).trigger("glozin_progress_bar_update",[85]);let l=.5;o.find("li.product").each(function(e,t){m(t).addClass("gz-fadeinup");m(t).css("--gz-fadeinup-delay",l+"s");l=l+.1});s.find("ul.products").attr("class",o.attr("class"));s.find("ul.products").html(o.html());r.html(a);s.find(".woocommerce-pagination").html(i);s.removeClass("loading");p.scrollTopFilterAJAX();p.$body.trigger("glozin_get_products_ajax_loaded");window.history.pushState(null,"",n);m(document.body).trigger("glozin_progress_bar_complete")})}};p.catalogOrderBy=function(){var t=m(".catalog-toolbar__orderby-form"),e=m(".catalog-toolbar__item .woocommerce-ordering");p.$body.on("click",".catalog-toolbar__orderby-default",function(e){e.preventDefault();var t=m(this).closest(".catalog-toolbar__orderby-form");t.toggleClass("glozin-active")}).on("keyup",function(e){if(e.keyCode===27){t.removeClass("glozin-active")}}).on("click",function(e){var t=m(e.target);if(t.parent(".catalog-toolbar__orderby-form").length){return}m(this).closest(".catalog-toolbar__orderby-form").removeClass("glozin-active")});p.$body.on("click",".catalog-toolbar__orderby-item",function(e){e.preventDefault();var t=m(this).data("id"),o=m(this).text(),i=m(this).closest(".catalog-toolbar__orderby-form"),a=p.$body.find(".woocommerce-ordering"),l=i.find(".catalog-toolbar__orderby-default-name"),n=m(this);a.find("option:selected").attr("selected",false);a.find("option[value="+t+"]").attr("selected","selected");l.text(o);m(".catalog-toolbar__orderby-form").removeClass("glozin-active");a.trigger("submit");if(p.$window.width()<768){m(".popover .popover__button-close").trigger("click")}setTimeout(function(){i.find(".catalog-toolbar__orderby-list .selected").removeClass("selected");n.addClass("selected")},100)});var o=e.find("option:selected").val();t.find(".catalog-toolbar__orderby-list a[data-id="+o+"]").addClass("selected")};p.loadMoreProducts=function(){if(m(".woocommerce-pagination").hasClass("woocommerce-pagination--infinite")){var e=false,t;m(window).on("scroll",function(){if(e){return}e=true;clearTimeout(t);o();setTimeout(function(){e=false},100);t=setTimeout(function(){e=false;o()},200)})}function o(){var t=m(".woocommerce-pagination.woocommerce-pagination--ajax"),o=m(".woocommerce-pagination-button",t);if(glozinIsVisible(t)&&o.length&&!o.hasClass("loading")){o.addClass("loading");a(o,function(e){o=t.find(".woocommerce-pagination-button")})}}if(m(".woocommerce-pagination").hasClass("woocommerce-pagination--loadmore")){p.$body.on("click",".woocommerce-pagination.woocommerce-pagination--loadmore .woocommerce-pagination-button",function(e){e.preventDefault();i()})}function i(){var t=m(".woocommerce-pagination.woocommerce-pagination--ajax"),o=m(".woocommerce-pagination-button",t);if(glozinIsVisible(t)&&o.length&&!o.hasClass("loading")){o.addClass("loading");a(o,function(e){o=t.find(".woocommerce-pagination-button")})}}function a(s,d){var c=s.closest(".woocommerce-pagination"),g=s.attr("href"),f=s.closest(".glozin-shop-content").find("ul.products").children().length,u=s.closest(".glozin-shop-content").find("li.gz-product-grid-banner");m(document.body).trigger("glozin_progress_bar_start");m.get(g,function(e){var t=m(".glozin-shop-content",e),o=m("ul.products",t),i=o.children(),a=m(".woocommerce-pagination.woocommerce-pagination--ajax",t),l=i.length+f,n=m(".gz-posts-found");i.appendTo(c.parent().find("ul.products"));if(a.length){s.replaceWith(m("a",a))}else{c.fadeOut(function(){c.remove()})}if("function"===typeof d){d(e)}i.addClass("gz-fadeinup gz-animated");let r=.5;i.each(function(e,t){jQuery(t).css("--gz-fadeinup-delay",r+"s");r=r+.1});p.$body.trigger("glozin_get_products_ajax_loaded",[i,true]);if(i.hasClass("gz-animated")){setTimeout(function(){i.removeClass("gz-animated")},10)}s.removeClass("loading");l=u.length?l-1:l;n.find(".current-post").html(" "+l);h();if(glozinData.shop_nav_ajax_url_change){window.history.pushState(null,"",g)}m(document.body).trigger("glozin_progress_bar_complete")})}function h(){var e=m(".gz-posts-found__inner"),t=e.find(".count-bar"),o=e.find(".current-post").html(),i=e.find(".found-post").html(),a=o/i*100;t.css("width",a+"%")}};p.sidebarPanel=function(){if(m(".glozin-catalog-page").hasClass("popup")){return}var e=m(".glozin-catalog-page #filter-sidebar-panel");p.$window.on("resize",function(){if(p.$window.width()>1024){if(e.length>0&&e.hasClass("offscreen-panel")){e.removeClass("offscreen-panel").removeAttr("style")}}else{if(e.length>0){e.addClass("offscreen-panel")}}}).trigger("resize")};m(function(){p.init()})})(jQuery);