jQuery(document).ready(function(t){t(".fb-img-comp-overlay").each(function(){const e=t(this),i=e.closest(".fb-image-comparison-slider-wrapper");if(0===i.length||i.find(".fb-image-comparison-slider").length>0)return;let s=!1;const n=i.attr("data-direction")||"horizontal";let o=i.attr("data-offset");if(o)try{o=JSON.parse(o)}catch(f){o={Desktop:50,Tablet:50,Mobile:50}}else o={Desktop:50,Tablet:50,Mobile:50};let c=50;const l=t(window).width();c=l<=767?void 0!==o.Mobile?o.Mobile:50:l<=1024?void 0!==o.Tablet?o.Tablet:50:void 0!==o.Desktop?o.Desktop:50;const a="vertical"===n;a?e.css({width:"","clip-path":`inset(0 0 ${100-c}% 0)`,"-webkit-clip-path":`inset(0 0 ${100-c}% 0)`}):e.css({width:"","clip-path":`inset(0 ${100-c}% 0 0)`,"-webkit-clip-path":`inset(0 ${100-c}% 0 0)`});const p=t('<div class="fb-image-comparison-slider"><div class="fb-slider-arrows"><span class="fb-arrow-left"></span><span class="fb-arrow-right"></span></div></div>');i.append(p),a?p.css({top:c+"%",left:"50%"}):p.css({left:c+"%",top:"50%"});const h="true"===i.attr("data-hover"),r="true"===i.attr("data-click");if(h)i.on("mousemove",function(t){const s=i[0].getBoundingClientRect();if(a){let i=t.clientY-s.top;i<0&&(i=0),i>s.height&&(i=s.height);const n=i/s.height*100;e.css({"clip-path":`inset(0 0 ${100-n}% 0)`,"-webkit-clip-path":`inset(0 0 ${100-n}% 0)`}),p.css({top:n+"%"})}else{let i=t.clientX-s.left;i<0&&(i=0),i>s.width&&(i=s.width);const n=i/s.width*100;e.css({"clip-path":`inset(0 ${100-n}% 0 0)`,"-webkit-clip-path":`inset(0 ${100-n}% 0 0)`}),p.css({left:n+"%"})}}),i.on("touchmove",function(t){const s=i[0].getBoundingClientRect(),n=t.originalEvent&&t.originalEvent.touches?t.originalEvent.touches[0]:t;if(a){let t=n.clientY-s.top;t<0&&(t=0),t>s.height&&(t=s.height);const i=t/s.height*100;e.css({"clip-path":`inset(0 0 ${100-i}% 0)`,"-webkit-clip-path":`inset(0 0 ${100-i}% 0)`}),p.css({top:i+"%"})}else{let t=n.clientX-s.left;t<0&&(t=0),t>s.width&&(t=s.width);const i=t/s.width*100;e.css({"clip-path":`inset(0 ${100-i}% 0 0)`,"-webkit-clip-path":`inset(0 ${100-i}% 0 0)`}),p.css({left:i+"%"})}});else{function d(t){const s=i[0].getBoundingClientRect(),n=s.width,o=s.height;if(0===n||0===o)return;const c=t.originalEvent&&t.originalEvent.touches?t.originalEvent.touches[0]:t;if(a){let t=c.clientY-s.top;t<0&&(t=0),t>o&&(t=o);const i=t/o*100;e.css({"clip-path":`inset(0 0 ${100-i}% 0)`,"-webkit-clip-path":`inset(0 0 ${100-i}% 0)`}),p.css({top:i+"%"})}else{let t=c.clientX-s.left;t<0&&(t=0),t>n&&(t=n);const i=t/n*100;e.css({"clip-path":`inset(0 ${100-i}% 0 0)`,"-webkit-clip-path":`inset(0 ${100-i}% 0 0)`}),p.css({left:i+"%"})}}(r?i:p).on("mousedown touchstart",function(e){t(e.target).closest(".fb-image-comparison-label").length>0||(e.preventDefault(),s=!0,r&&d(e))}),t(window).on("mouseup touchend",function(){s=!1}),t(window).on("mousemove touchmove",function(t){s&&d(t)})}})});