!function(e){e.fn.twentytwenty=function(t){return t=e.extend({default_offset_pct:.5,orientation:"horizontal",switch_before_label:!0,before_label:"Before",switch_after_label:!0,after_label:"After",no_overlay:!1,move_slider_on_hover:!1,move_with_handle_only:!0,click_to_move:!1,show_drag:!0,show_sep:!0,horbeforePos:"middle",horafterPos:"middle",verbeforePos:"center",verafterPos:"center"},t),this.each(function(){var n=t.default_offset_pct,a=e(this),i=t.orientation,r="vertical"===i?"down":"left",s="vertical"===i?"up":"right";t.no_overlay?a.append("<div class='premium-twentytwenty-overlay premium-twentytwenty-hide'></div>"):a.append("<div class='premium-twentytwenty-overlay premium-twentytwenty-show'></div>");var o=a.find("img:first"),l=a.find("img:last");t.show_sep?a.append("<div class='premium-twentytwenty-handle'></div>"):a.append("<div class='premium-twentytwenty-handle premium-twentytwenty-hide'></div>");var d=a.find(".premium-twentytwenty-handle");d.append("<span class='premium-twentytwenty-"+r+"-arrow'></span>"),d.append("<span class='premium-twentytwenty-"+s+"-arrow'></span>"),a.addClass("premium-twentytwenty-container"),o.addClass("premium-twentytwenty-before"),l.addClass("premium-twentytwenty-after"),t.show_drag||d.css("opacity","0");var p=a.find(".premium-twentytwenty-overlay");if(t.switch_before_label){var c="<div class='premium-twentytwenty-before-label premium-twentytwenty-before-label-"+t.horbeforePos+" premium-twentytwenty-before-label-"+t.verbeforePos+"'><span>"+t.before_label+"</span></div>";p.append(c)}if(t.switch_after_label){var m="<div class='premium-twentytwenty-after-label  premium-twentytwenty-after-label-"+t.horafterPos+" premium-twentytwenty-after-label-"+t.verafterPos+"'><span>"+t.after_label+"</span></div>";p.append(m)}var f=function(t){var n,r,s,p,c=(n=t,{w:(r=o.width())+"px",h:(s=o.height())+"px",cw:n*r+"px",ch:n*s+"px"}),m=e(a).find(".premium-twentytwenty-before-label"),f=e(a).find(".premium-twentytwenty-after-label");if(d.css("vertical"===i?"top":"left","vertical"===i?c.ch:c.cw),"horizontal"===i){var w=void 0!==m.css("left")?parseInt(m.css("left").replace(/px/,"")):"",v=parseInt(m.outerWidth()),h=void 0!==f.css("left")?parseInt(f.css("left").replace(/px/,"")):"";(u=parseInt(d.css("left").replace(/px/,"")))<w+v?m.addClass("premium-label-hidden"):m.removeClass("premium-label-hidden"),u>h?f.addClass("premium-label-hidden"):f.removeClass("premium-label-hidden")}else{var u;w=void 0!==m.css("top")?parseInt(m.css("top").replace(/px/,"")):"",v=parseInt(m.outerHeight()),h=void 0!==f.css("top")?parseInt(f.css("top").replace(/px/,"")):"",(u=parseInt(d.css("top").replace(/px/,"")))<w+v?m.addClass("premium-label-hidden"):m.removeClass("premium-label-hidden"),u>h&&!(h<0)?f.addClass("premium-label-hidden"):f.removeClass("premium-label-hidden")}p=c,"vertical"===i?(o.css("clip","rect(0,"+p.w+","+p.ch+",0)"),l.css("clip","rect("+p.ch+","+p.w+","+p.h+",0)")):(o.css("clip","rect(0,"+p.cw+","+p.h+",0)"),l.css("clip","rect(0,"+p.w+","+p.h+","+p.cw+")")),a.css("height",p.h)},w=function(e,t){var n;return n="vertical"===i?(t-h)/y:(e-v)/u,0,1,Math.max(0,Math.min(1,n))};e(window).on("resize.twentytwenty",function(e){f(n)}),a.on("updateRatio",function(e,t){f(t)});var v=0,h=0,u=0,y=0,_=function(e){(e.distX>e.distY&&e.distX<-e.distY||e.distX<e.distY&&e.distX>-e.distY)&&"vertical"!==i?e.preventDefault():(e.distX<e.distY&&e.distX<-e.distY||e.distX>e.distY&&e.distX>-e.distY)&&"vertical"===i&&e.preventDefault(),a.addClass("active"),v=a.offset().left,h=a.offset().top,u=o.width(),y=o.height()},b=function(e){a.hasClass("active")&&(n=w(e.pageX,e.pageY),f(n))},g=function(){a.removeClass("active")},C=t.move_with_handle_only?d:a;C.on("movestart",_),C.on("move",b),C.on("moveend",g),t.move_slider_on_hover&&(a.on("mouseenter",_),a.on("mousemove",b),a.on("mouseleave",g)),d.on("touchmove",function(e){e.preventDefault()}),a.find("img").on("mousedown",function(e){e.preventDefault()}),t.click_to_move&&a.on("click",function(e){v=a.offset().left,h=a.offset().top,u=o.width(),y=o.height(),n=w(e.pageX,e.pageY),f(n)}),e(window).trigger("resize.twentytwenty")})}}(jQuery);