(()=>{"use strict";const e=class{constructor(e){this.slider=e,this.slider&&(this.sliderInput=this.slider.querySelector("[data-ablocks-slider-input]"),this.moveOnHover="true"===this.slider.getAttribute("data-ablocks-move-on-hover"),this.sliderOrientation=this.slider.getAttribute("data-ablocks-slider-orientation"),this.sliderInput&&this.sliderInput.addEventListener("input",e=>{this.updateSliderPosition(e.target.value)}),this.moveOnHover&&this.slider.addEventListener("mousemove",e=>{this.handleMouseMove(e)}))}updateSliderPosition(e){const t=this.slider.querySelector(".ablocks-image-comparison__before-image"),i=this.slider.querySelector(".ablocks-image-comparison__slider-line"),s=this.slider.querySelector(".ablocks-image-comparison__slider-icon");"horizontal"===this.sliderOrientation?(t.style.width=e+"%",i.style.left=e+"%",s.style.left=e+"%"):(t.style.height=e+"%",i.style.top=e+"%",s.style.top=e+"%")}handleMouseMove(e){const t=this.slider.getBoundingClientRect();let i;if("horizontal"===this.sliderOrientation){const s=e.clientX-t.left;i=Math.round(s/t.width*100)}else{const s=e.clientY-t.top;i=Math.round(s/t.height*100)}i=Math.max(0,Math.min(100,i)),this.sliderInput&&(this.sliderInput.value=i,this.updateSliderPosition(i))}};document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("[data-ablocks-slider-container]").forEach(t=>{new e(t)})})})();