class VamtamHrScrolling extends elementorModules.frontend.handlers.Base{getDefaultSettings(){return{selectors:{container:".elementor-widget-container",items:".products.elementor-grid, .elementor-posts-container"}}}getDefaultElements(){const selectors=this.getSettings("selectors");return{$container:this.$element.find(selectors.container),$items:this.$element.find(selectors.items)}}onInit(...args){super.onInit(...args),this.checkHandleHrLayout()}checkHandleHrLayout(){const hasHrLayout=this.$element.hasClass("vamtam-has-hr-layout"),hasNav=this.$element.hasClass("vamtam-has-nav");hasHrLayout&&hasNav&&this.handleHrLayoutNavigation()}handleHrLayoutNavigation(){const addNavElements=()=>{const $navigation=jQuery('<div class="vamtam-nav">\n\t\t\t\t\t<span class="vamtam-nav-btn vamtam-nav-btn-prev">\n\t\t\t\t\t\t<i class="vamtamtheme- vamtam-theme-arrow-left"></i>\n\t\t\t\t\t</span>\n\t\t\t\t\t<span class="vamtam-nav-btn vamtam-nav-btn-next">\n\t\t\t\t\t\t<i class="vamtamtheme- vamtam-theme-arrow-right"></i>\n\t\t\t\t\t</span>\n\t\t\t\t</div>');this.elements.$items.after($navigation)},bindNavEvents=()=>{const colGapPropName=this.getWidgetType().includes("posts")?"--grid-column-gap":"--vamtam-col-gap",onNavBtnClick=e=>{e.preventDefault();const $items=this.elements.$items,visibleWidth=$items.width(),isNext=jQuery(e.target).hasClass("vamtam-nav-btn-next");let colGap=parseFloat(this.getCachedCSSPropForDevice(colGapPropName))||0,colHint=this.normalizeMultiUnitValue(this.getCachedCSSPropForDevice("--vamtam-col-hint"));colHint<0?colHint=0:colGap=0,isNext?$items.scrollLeft($items.scrollLeft()+visibleWidth+colGap-colHint):$items.scrollLeft($items.scrollLeft()-visibleWidth-colGap+colHint)};jQuery(this.$element.find(".vamtam-nav-btn")).off("click").on("click",onNavBtnClick);const onItemsScroll=e=>{const items=this.elements.$items[0],$items=this.elements.$items;0===items.scrollLeft?(this.$element.find(".vamtam-nav-btn-prev").addClass("disabled"),this.$element.find(".vamtam-nav-btn-next").removeClass("disabled")):items.scrollLeft===items.scrollWidth-$items.width()?(this.$element.find(".vamtam-nav-btn-prev").removeClass("disabled"),this.$element.find(".vamtam-nav-btn-next").addClass("disabled")):(this.$element.find(".vamtam-nav-btn-prev").removeClass("disabled"),this.$element.find(".vamtam-nav-btn-next").removeClass("disabled"))},onItemsScrollDebounced200=window.VAMTAM.debounce(onItemsScroll,200),onItemsScrollDebounced500=window.VAMTAM.debounce(onItemsScroll,500);this.elements.$items.off("scroll",onItemsScrollDebounced200),this.elements.$items.on("scroll",onItemsScrollDebounced200),jQuery(window).off("resize",onItemsScrollDebounced500),jQuery(window).on("resize",onItemsScrollDebounced500),this.elements.$items.trigger("scroll")};addNavElements(),bindNavEvents()}normalizeMultiUnitValue(valWithUnit){let normalizedVal=0;if(valWithUnit.includes("px"))return normalizedVal=parseFloat(valWithUnit)||0,normalizedVal;if(valWithUnit.includes("%")){const width=this.$element.width();return normalizedVal=parseFloat(valWithUnit)/100*width,normalizedVal}if(valWithUnit.includes("em")){const fontSize=parseFloat(this.$element.parent().css("font-size"));return normalizedVal=parseFloat(fontSize)*parseFloat(valWithUnit),normalizedVal}return 0}getCachedCSSPropForDevice(propName){if(!propName)return"";const curDevice=jQuery("body").attr("data-elementor-device-mode");return this.cachedProps||(this.cachedProps={}),this.cachedProps[curDevice]||(this.cachedProps[curDevice]={}),this.cachedProps[curDevice][propName]||(this.cachedProps[curDevice][propName]=getComputedStyle(this.$element[0]).getPropertyValue(propName)),this.cachedProps[curDevice][propName]}}jQuery(window).on("elementor/frontend/init",()=>{const attachTo=[{name:"woocommerce-products",skin:"default"},{name:"woocommerce-product-related",skin:"default"},{name:"woocommerce-product-upsell",skin:"default"},{name:"posts",skin:"classic"},{name:"posts",skin:"vamtam_classic"},{name:"archive-posts",skin:"archive_classic"},{name:"archive-posts",skin:"vamtam_classic"}];if(elementorFrontend.elementsHandler&&elementorFrontend.elementsHandler.attachHandler)attachTo.forEach(widget=>{elementorFrontend.elementsHandler.attachHandler(widget.name,VamtamHrScrolling,widget.skin)});else{const addHandler=$element=>{elementorFrontend.elementsHandler.addHandler(VamtamHrScrolling,{$element:$element})};attachTo.forEach(widget=>{elementorFrontend.hooks.addAction(`frontend/element_ready/${widget.name}.${widget.skin}`,addHandler,100)})}});