!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).lgZoom=t()}(this,function(){"use strict";var o=function(){return(o=Object.assign||function(e){for(var t,o=1,i=arguments.length;o':"";this.settings.actualSize&&(e+=''),this.core.outer.addClass("lg-use-transition-for-zoom"),this.core.$toolbar.first().append(e)},h.prototype.enableZoom=function(e){var t=this,o=this.settings.enableZoomAfter+e.detail.delay;this.$LG("body").first().hasClass("lg-from-hash")&&e.detail.delay?o=0:this.$LG("body").first().removeClass("lg-from-hash"),this.zoomableTimeout=setTimeout(function(){t.isImageSlide(t.core.index)&&(t.core.getSlideItem(e.detail.index).addClass("lg-zoomable"),e.detail.index===t.core.index&&t.setZoomEssentials())},o+30)},h.prototype.enableZoomOnSlideItemLoad=function(){this.core.LGel.on(n+".zoom",this.enableZoom.bind(this))},h.prototype.getDragCords=function(e){return{x:e.pageX,y:e.pageY}},h.prototype.getSwipeCords=function(e){return{x:e.touches[0].pageX,y:e.touches[0].pageY}},h.prototype.getDragAllowedAxises=function(e,t){var o=this.core.getSlideItem(this.core.index).find(".lg-image").first().get(),i=0,s=0,n=o.getBoundingClientRect(),s=e?(i=o.offsetHeight*e,o.offsetWidth*e):t?(i=n.height+t*n.height,n.width+t*n.width):(i=n.height,n.width),o=i>this.containerRect.height;return{allowX:s>this.containerRect.width,allowY:o}},h.prototype.setZoomEssentials=function(){this.containerRect=this.core.$content.get().getBoundingClientRect()},h.prototype.zoomImage=function(e,t,o,i){var s,n,a,r,l,g,c,h;Math.abs(t)<=0||(l=this.containerRect.width/2+this.containerRect.left,c=this.containerRect.height/2+this.containerRect.top+this.scrollTop,1===e&&(this.positionChanged=!1),s=(n=this.getDragAllowedAxises(0,t)).allowY,n=n.allowX,this.positionChanged&&(a=this.left/(this.scale-t),r=this.top/(this.scale-t),this.pageX=l-a,this.pageY=c-r,this.positionChanged=!1),a=this.getPossibleSwipeDragCords(t),r=l-this.pageX,l=c-this.pageY,c=1a.maxX&&(g=a.maxX)),s?this.isBeyondPossibleTop(c,a.minY)?c=a.minY:this.isBeyondPossibleBottom(c,a.maxY)&&(c=a.maxY):1a.maxY&&(c=a.maxY))),this.setZoomStyles({x:g,y:c,scale:e}),this.left=g,this.top=c,i&&this.setZoomImageSize())},h.prototype.resetImageTranslate=function(e){var t;this.isImageSlide(e)&&(t=this.core.getSlideItem(e).find(".lg-image").first(),this.imageReset=!1,t.removeClass("reset-transition reset-transition-y reset-transition-x"),this.core.outer.removeClass("lg-actual-size"),t.css("width","auto").css("height","auto"),setTimeout(function(){t.removeClass("no-transition")},10))},h.prototype.setZoomImageSize=function(){var t=this,o=this.core.getSlideItem(this.core.index).find(".lg-image").first();setTimeout(function(){var e=t.getCurrentImageActualSizeScale();t.scale>=e&&(o.addClass("no-transition"),t.imageReset=!0)},500),setTimeout(function(){var e=t.getCurrentImageActualSizeScale();t.scale>=e&&(e=t.getDragAllowedAxises(t.scale),o.css("width",o.get().naturalWidth+"px").css("height",o.get().naturalHeight+"px"),t.core.outer.addClass("lg-actual-size"),e.allowX&&e.allowY?o.addClass("reset-transition"):e.allowX&&!e.allowY?o.addClass("reset-transition-x"):!e.allowX&&e.allowY&&o.addClass("reset-transition-y"))},550)},h.prototype.setZoomStyles=function(e){var t=this.core.getSlideItem(this.core.index).find(".lg-img-wrap").first(),o=this.core.getSlideItem(this.core.index).find(".lg-image").first(),i=this.core.outer.find(".lg-current .lg-dummy-img").first(),o=(this.scale=e.scale,o.css("transform","scale3d("+e.scale+", "+e.scale+", 1)"),i.css("transform","scale3d("+e.scale+", "+e.scale+", 1)"),"translate3d("+e.x+"px, "+e.y+"px, 0)");t.css("transform",o)},h.prototype.setActualSize=function(e,o){var i,s=this;this.zoomInProgress||(this.zoomInProgress=!0,i=this.core.galleryItems[this.core.index],this.resetImageTranslate(e),setTimeout(function(){var e,t;i.src&&!s.core.outer.hasClass("lg-first-slide-loading")&&(e=s.getCurrentImageActualSizeScale(),t=s.scale,s.core.outer.hasClass("lg-zoomed")?s.scale=1:s.scale=s.getScale(e),s.setPageCords(o),s.beginZoom(s.scale),s.zoomImage(s.scale,s.scale-t,!0,!0))},50),setTimeout(function(){s.core.outer.removeClass("lg-grabbing").addClass("lg-grab")},60),setTimeout(function(){s.zoomInProgress=!1},610))},h.prototype.getNaturalWidth=function(e){var t=this.core.getSlideItem(e).find(".lg-image").first(),e=this.core.galleryItems[e].width;return e?parseFloat(e):t.get().naturalWidth},h.prototype.getActualSizeScale=function(e,t){e=t<=e?e/t||2:1;return e},h.prototype.getCurrentImageActualSizeScale=function(){var e=this.core.getSlideItem(this.core.index).find(".lg-image").first().get().offsetWidth,t=this.getNaturalWidth(this.core.index)||e;return this.getActualSizeScale(t,e)},h.prototype.getPageCords=function(e){var t={};return e?(t.x=e.pageX||e.touches[0].pageX,t.y=e.pageY||e.touches[0].pageY):(e=this.core.$content.get().getBoundingClientRect(),t.x=e.width/2+e.left,t.y=e.height/2+this.scrollTop+e.top),t},h.prototype.setPageCords=function(e){e=this.getPageCords(e);this.pageX=e.x,this.pageY=e.y},h.prototype.manageActualPixelClassNames=function(){this.core.getElementById("lg-actual-size").removeClass(this.settings.actualSizeIcons.zoomIn).addClass(this.settings.actualSizeIcons.zoomOut)},h.prototype.beginZoom=function(e){return this.core.outer.removeClass("lg-zoom-drag-transition lg-zoom-dragging"),1=e&&(t=e-o.scale,o.zoomImage(e,t=0===t?.01:t,!1,!0)),o.manageActualPixelClassNames(),o.core.outer.addClass("lg-zoomed")),o.core.touchAction=void 0)})},h.prototype.touchendZoom=function(e,t,o,i,s){var n=t.x-e.x,t=t.y-e.y,e=Math.abs(n)/s+1,s=Math.abs(t)/s+1,e=(2