filesafe/public/libs/simple-lightbox/simple-lightbox.min.js
2022-09-30 04:02:28 +07:00

1 line
45 KiB
JavaScript

!function i(n,s,a){function r(e,t){if(!s[e]){if(!n[e]){var o="function"==typeof require&&require;if(!t&&o)return o(e,!0);if(l)return l(e,!0);throw(o=new Error("Cannot find module '"+e+"'")).code="MODULE_NOT_FOUND",o}o=s[e]={exports:{}},n[e][0].call(o.exports,function(t){return r(n[e][1][t]||t)},o,o.exports,i,n,s,a)}return s[e].exports}for(var l="function"==typeof require&&require,t=0;t<a.length;t++)r(a[t]);return r}({1:[function(t,e,o){!function(e){!function(){"use strict";function h(t){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function m(t,e){var o="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!o){if(Array.isArray(t)||(o=function(t,e){if(t){if("string"==typeof t)return r(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(o="Object"===o&&t.constructor?t.constructor.name:o)||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?r(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){o&&(t=o);var i=0,e=function(){};return{s:e,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,s=!0,a=!1;return{s:function(){o=o.call(t)},n:function(){var t=o.next();return s=t.done,t},e:function(t){a=!0,n=t},f:function(){try{s||null==o.return||o.return()}finally{if(a)throw n}}}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,i=new Array(e);o<e;o++)i[o]=t[o];return i}function i(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function s(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}Object.defineProperty(o,"__esModule",{value:!0}),o.default=void 0;var t=function(){function n(t,e){var o,i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),s(this,"defaultOptions",{sourceAttr:"href",overlay:!0,overlayOpacity:.7,spinner:!0,nav:!0,navText:["&lsaquo;","&rsaquo;"],captions:!0,captionDelay:0,captionSelector:"img",captionType:"attr",captionsData:"title",captionPosition:"bottom",captionClass:"",close:!0,closeText:"&times;",swipeClose:!0,showCounter:!0,fileExt:"png|jpg|jpeg|gif|webp",animationSlide:!0,animationSpeed:250,preloading:!0,enableKeyboard:!0,loop:!0,rel:!1,docClose:!0,swipeTolerance:50,className:"simple-lightbox",widthRatio:.8,heightRatio:.9,scaleImageToRatio:!1,disableRightClick:!1,disableScroll:!0,alertError:!0,alertErrorMessage:"Image not found, next image will be loaded",additionalHtml:!1,history:!0,throttleInterval:0,doubleTapZoom:2,maxZoom:10,htmlClass:"has-lightbox",rtl:!1,fixedClass:"sl-fixed",fadeSpeed:300,uniqueImages:!0,focus:!0,scrollZoom:!0,scrollZoomFactor:.5}),s(this,"transitionPrefix",void 0),s(this,"isPassiveEventsSupported",void 0),s(this,"transitionCapable",!1),s(this,"isTouchDevice","ontouchstart"in window),s(this,"isAppleDevice",/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)),s(this,"initialLocationHash",void 0),s(this,"pushStateSupport","pushState"in history),s(this,"isOpen",!1),s(this,"isAnimating",!1),s(this,"isClosing",!1),s(this,"isFadeIn",!1),s(this,"urlChangedOnce",!1),s(this,"hashReseted",!1),s(this,"historyHasChanges",!1),s(this,"historyUpdateTimeout",null),s(this,"currentImage",void 0),s(this,"eventNamespace","simplelightbox"),s(this,"domNodes",{}),s(this,"loadedImages",[]),s(this,"initialImageIndex",0),s(this,"currentImageIndex",0),s(this,"initialSelector",null),s(this,"globalScrollbarWidth",0),s(this,"controlCoordinates",{swipeDiff:0,swipeYDiff:0,swipeStart:0,swipeEnd:0,swipeYStart:0,swipeYEnd:0,mousedown:!1,imageLeft:0,zoomed:!1,containerHeight:0,containerWidth:0,containerOffsetX:0,containerOffsetY:0,imgHeight:0,imgWidth:0,capture:!1,initialOffsetX:0,initialOffsetY:0,initialPointerOffsetX:0,initialPointerOffsetY:0,initialPointerOffsetX2:0,initialPointerOffsetY2:0,initialScale:1,initialPinchDistance:0,pointerOffsetX:0,pointerOffsetY:0,pointerOffsetX2:0,pointerOffsetY2:0,targetOffsetX:0,targetOffsetY:0,targetScale:0,pinchOffsetX:0,pinchOffsetY:0,limitOffsetX:0,limitOffsetY:0,scaleDifference:0,targetPinchDistance:0,touchCount:0,doubleTapped:!1,touchmoveCount:0}),this.options=Object.assign(this.defaultOptions,e),this.isPassiveEventsSupported=this.checkPassiveEventsSupport(),"string"==typeof t?(this.initialSelector=t,this.elements=Array.from(document.querySelectorAll(t))):this.elements=void 0!==t.length&&0<t.length?Array.from(t):[t],this.relatedElements=[],this.transitionPrefix=this.calculateTransitionPrefix(),this.transitionCapable=!1!==this.transitionPrefix,this.initialLocationHash=this.hash,this.options.rel&&(this.elements=this.getRelated(this.options.rel)),this.options.uniqueImages&&(o=[],this.elements=Array.from(this.elements).filter(function(t){t=t.getAttribute(i.options.sourceAttr);return-1===o.indexOf(t)&&(o.push(t),!0)})),this.createDomNodes(),this.options.close&&this.domNodes.wrapper.appendChild(this.domNodes.closeButton),this.options.nav&&this.domNodes.wrapper.appendChild(this.domNodes.navigation),this.options.spinner&&this.domNodes.wrapper.appendChild(this.domNodes.spinner),this.addEventListener(this.elements,"click."+this.eventNamespace,function(t){if(i.isValidLink(t.currentTarget)){if(t.preventDefault(),i.isAnimating)return!1;i.initialImageIndex=i.elements.indexOf(t.currentTarget),i.openImage(t.currentTarget)}}),this.options.docClose&&this.addEventListener(this.domNodes.wrapper,["click."+this.eventNamespace,"touchstart."+this.eventNamespace],function(t){i.isOpen&&t.target===t.currentTarget&&i.close()}),this.options.disableRightClick&&this.addEventListener(document.body,"contextmenu."+this.eventNamespace,function(t){t.target.parentElement.classList.contains("sl-image")&&t.preventDefault()}),this.options.enableKeyboard&&this.addEventListener(document.body,"keyup."+this.eventNamespace,this.throttle(function(t){return i.controlCoordinates.swipeDiff=0,i.isAnimating&&"Escape"===t.key?(i.currentImage.setAttribute("src",""),i.isAnimating=!1,i.close()):void(i.isOpen&&(t.preventDefault(),"Escape"===t.key&&i.close(),!i.isAnimating&&-1<["ArrowLeft","ArrowRight"].indexOf(t.key)&&i.loadImage("ArrowRight"===t.key?1:-1)))},this.options.throttleInterval)),this.addEvents()}var t,e,o;return t=n,(e=[{key:"checkPassiveEventsSupport",value:function(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}return t}},{key:"createDomNodes",value:function(){this.domNodes.overlay=document.createElement("div"),this.domNodes.overlay.classList.add("sl-overlay"),this.domNodes.overlay.dataset.opacityTarget=this.options.overlayOpacity,this.domNodes.closeButton=document.createElement("button"),this.domNodes.closeButton.classList.add("sl-close"),this.domNodes.closeButton.innerHTML=this.options.closeText,this.domNodes.spinner=document.createElement("div"),this.domNodes.spinner.classList.add("sl-spinner"),this.domNodes.spinner.innerHTML="<div></div>",this.domNodes.navigation=document.createElement("div"),this.domNodes.navigation.classList.add("sl-navigation"),this.domNodes.navigation.innerHTML='<button class="sl-prev">'.concat(this.options.navText[0],'</button><button class="sl-next">').concat(this.options.navText[1],"</button>"),this.domNodes.counter=document.createElement("div"),this.domNodes.counter.classList.add("sl-counter"),this.domNodes.counter.innerHTML='<span class="sl-current"></span>/<span class="sl-total"></span>',this.domNodes.caption=document.createElement("div"),this.domNodes.caption.classList.add("sl-caption","pos-"+this.options.captionPosition),this.options.captionClass&&this.domNodes.caption.classList.add(this.options.captionClass),this.domNodes.image=document.createElement("div"),this.domNodes.image.classList.add("sl-image"),this.domNodes.wrapper=document.createElement("div"),this.domNodes.wrapper.classList.add("sl-wrapper"),this.domNodes.wrapper.setAttribute("tabindex",-1),this.domNodes.wrapper.setAttribute("role","dialog"),this.domNodes.wrapper.setAttribute("aria-hidden",!1),this.options.className&&this.domNodes.wrapper.classList.add(this.options.className),this.options.rtl&&this.domNodes.wrapper.classList.add("sl-dir-rtl")}},{key:"throttle",value:function(t,e){var o;return function(){o||(t.apply(this,arguments),o=!0,setTimeout(function(){return o=!1},e))}}},{key:"isValidLink",value:function(t){return!this.options.fileExt||t.getAttribute(this.options.sourceAttr)&&new RegExp("("+this.options.fileExt+")$","i").test(t.getAttribute(this.options.sourceAttr))}},{key:"calculateTransitionPrefix",value:function(){var t=(document.body||document.documentElement).style;return"transition"in t?"":"WebkitTransition"in t?"-webkit-":"MozTransition"in t?"-moz-":"OTransition"in t&&"-o"}},{key:"toggleScrollbar",value:function(t){var e,i=0,o=[].slice.call(document.querySelectorAll("."+this.options.fixedClass));return"hide"===t?((t=window.innerWidth)||(t=(e=document.documentElement.getBoundingClientRect()).right-Math.abs(e.left)),(document.body.clientWidth<t||this.isAppleDevice)&&(e=document.createElement("div"),t=parseInt(document.body.style.paddingRight||0,10),e.classList.add("sl-scrollbar-measure"),document.body.appendChild(e),i=e.offsetWidth-e.clientWidth,document.body.removeChild(e),document.body.dataset.originalPaddingRight=t,(0<i||0==i&&this.isAppleDevice)&&(document.body.classList.add("hidden-scroll"),document.body.style.paddingRight=t+i+"px",o.forEach(function(t){var e=t.style.paddingRight,o=window.getComputedStyle(t)["padding-right"];t.dataset.originalPaddingRight=e,t.style.paddingRight="".concat(parseFloat(o)+i,"px")})))):(document.body.classList.remove("hidden-scroll"),document.body.style.paddingRight=document.body.dataset.originalPaddingRight,o.forEach(function(t){var e=t.dataset.originalPaddingRight;void 0!==e&&(t.style.paddingRight=e)})),i}},{key:"close",value:function(){var t=this;if(!this.isOpen||this.isAnimating||this.isClosing)return!1;this.isClosing=!0;var e,o=this.relatedElements[this.currentImageIndex];for(e in o.dispatchEvent(new Event("close.simplelightbox")),this.options.history&&(this.historyHasChanges=!1,this.hashReseted||this.resetHash()),this.removeEventListener(document,"focusin."+this.eventNamespace),this.fadeOut(this.domNodes.overlay,this.options.fadeSpeed),this.fadeOut(document.querySelectorAll(".sl-image img, .sl-close, .sl-navigation, .sl-image .sl-caption, .sl-counter"),this.options.fadeSpeed,function(){t.options.disableScroll&&t.toggleScrollbar("show"),t.options.htmlClass&&""!==t.options.htmlClass&&document.querySelector("html").classList.remove(t.options.htmlClass),document.body.removeChild(t.domNodes.wrapper),document.body.removeChild(t.domNodes.overlay),t.domNodes.additionalHtml=null,o.dispatchEvent(new Event("closed.simplelightbox")),t.isClosing=!1}),this.currentImage=null,this.isOpen=!1,this.isAnimating=!1,this.controlCoordinates)this.controlCoordinates[e]=0;this.controlCoordinates.mousedown=!1,this.controlCoordinates.zoomed=!1,this.controlCoordinates.capture=!1,this.controlCoordinates.initialScale=this.minMax(1,1,this.options.maxZoom),this.controlCoordinates.doubleTapped=!1}},{key:"hash",get:function(){return window.location.hash.substring(1)}},{key:"preload",value:function(){var e=this,o=this.currentImageIndex,t=this.relatedElements.length,i=o+1<0?t-1:t-1<=o+1?0:o+1,n=o-1<0?t-1:t-1<=o-1?0:o-1,s=new Image,t=new Image;s.addEventListener("load",function(t){t=t.target.getAttribute("src");-1===e.loadedImages.indexOf(t)&&e.loadedImages.push(t),e.relatedElements[o].dispatchEvent(new Event("nextImageLoaded."+e.eventNamespace))}),s.setAttribute("src",this.relatedElements[i].getAttribute(this.options.sourceAttr)),t.addEventListener("load",function(t){t=t.target.getAttribute("src");-1===e.loadedImages.indexOf(t)&&e.loadedImages.push(t),e.relatedElements[o].dispatchEvent(new Event("prevImageLoaded."+e.eventNamespace))}),t.setAttribute("src",this.relatedElements[n].getAttribute(this.options.sourceAttr))}},{key:"loadImage",value:function(t){var e=this,o=t;this.options.rtl&&(t=-t),this.relatedElements[this.currentImageIndex].dispatchEvent(new Event("change."+this.eventNamespace)),this.relatedElements[this.currentImageIndex].dispatchEvent(new Event((1===t?"next":"prev")+"."+this.eventNamespace));t=this.currentImageIndex+t;if(this.isAnimating||(t<0||t>=this.relatedElements.length)&&!1===this.options.loop)return!1;this.currentImageIndex=t<0?this.relatedElements.length-1:t>this.relatedElements.length-1?0:t,this.domNodes.counter.querySelector(".sl-current").innerHTML=this.currentImageIndex+1,this.options.animationSlide&&this.slide(this.options.animationSpeed/1e3,-100*o-this.controlCoordinates.swipeDiff+"px"),this.fadeOut(this.domNodes.image,this.options.fadeSpeed,function(){e.isAnimating=!0,e.isClosing?e.isAnimating=!1:setTimeout(function(){var t=e.relatedElements[e.currentImageIndex];e.currentImage.setAttribute("src",t.getAttribute(e.options.sourceAttr)),-1===e.loadedImages.indexOf(t.getAttribute(e.options.sourceAttr))&&e.show(e.domNodes.spinner),e.domNodes.image.contains(e.domNodes.caption)&&e.domNodes.image.removeChild(e.domNodes.caption),e.adjustImage(o),e.options.preloading&&e.preload()},100)})}},{key:"adjustImage",value:function(s){var a=this;if(!this.currentImage)return!1;var t=new Image,r=window.innerWidth*this.options.widthRatio,l=window.innerHeight*this.options.heightRatio;t.setAttribute("src",this.currentImage.getAttribute("src")),this.currentImage.dataset.scale=1,this.currentImage.dataset.translateX=0,this.currentImage.dataset.translateY=0,this.zoomPanElement(0,0,1),t.addEventListener("error",function(t){a.relatedElements[a.currentImageIndex].dispatchEvent(new Event("error."+a.eventNamespace)),a.isAnimating=!1,a.isOpen=!0,a.domNodes.spinner.style.display="none";var e=1===s||-1===s;if(a.initialImageIndex===a.currentImageIndex&&e)return a.close();a.options.alertError&&alert(a.options.alertErrorMessage),a.loadImage(e?s:1)}),t.addEventListener("load",function(t){void 0!==s&&(a.relatedElements[a.currentImageIndex].dispatchEvent(new Event("changed."+a.eventNamespace)),a.relatedElements[a.currentImageIndex].dispatchEvent(new Event((1===s?"nextDone":"prevDone")+"."+a.eventNamespace))),a.options.history&&a.updateURL(),-1===a.loadedImages.indexOf(a.currentImage.getAttribute("src"))&&a.loadedImages.push(a.currentImage.getAttribute("src"));var e,o,i=t.target.width,n=t.target.height;(a.options.scaleImageToRatio||r<i||l<n)&&(i/=t=r/l<i/n?i/r:n/l,n/=t),a.domNodes.image.style.top=(window.innerHeight-n)/2+"px",a.domNodes.image.style.left=(window.innerWidth-i-a.globalScrollbarWidth)/2+"px",a.domNodes.image.style.width=i+"px",a.domNodes.image.style.height=n+"px",a.domNodes.spinner.style.display="none",a.options.focus&&a.forceFocus(),a.fadeIn(a.currentImage,a.options.fadeSpeed,function(){a.options.focus&&a.domNodes.wrapper.focus()}),a.isOpen=!0,"string"==typeof a.options.captionSelector?e="self"===a.options.captionSelector?a.relatedElements[a.currentImageIndex]:a.relatedElements[a.currentImageIndex].querySelector(a.options.captionSelector):"function"==typeof a.options.captionSelector&&(e=a.options.captionSelector(a.relatedElements[a.currentImageIndex])),a.options.captions&&e&&(o="data"===a.options.captionType?e.dataset[a.options.captionsData]:"text"===a.options.captionType?e.innerHTML:e.getAttribute(a.options.captionsData)),a.options.loop?1===a.relatedElements.length?a.hide(a.domNodes.navigation.querySelectorAll(".sl-prev, .sl-next")):a.show(a.domNodes.navigation.querySelectorAll(".sl-prev, .sl-next")):(0===a.currentImageIndex&&a.hide(a.domNodes.navigation.querySelector(".sl-prev")),a.currentImageIndex>=a.relatedElements.length-1&&a.hide(a.domNodes.navigation.querySelector(".sl-next")),0<a.currentImageIndex&&a.show(a.domNodes.navigation.querySelector(".sl-prev")),a.currentImageIndex<a.relatedElements.length-1&&a.show(a.domNodes.navigation.querySelector(".sl-next"))),1===s||-1===s?(a.options.animationSlide&&(a.slide(0,100*s+"px"),setTimeout(function(){a.slide(a.options.animationSpeed/1e3,"0px")},50)),a.fadeIn(a.domNodes.image,a.options.fadeSpeed,function(){a.isAnimating=!1,a.setCaption(o,i)})):(a.isAnimating=!1,a.setCaption(o,i)),a.options.additionalHtml&&!a.domNodes.additionalHtml&&(a.domNodes.additionalHtml=document.createElement("div"),a.domNodes.additionalHtml.classList.add("sl-additional-html"),a.domNodes.additionalHtml.innerHTML=a.options.additionalHtml,a.domNodes.image.appendChild(a.domNodes.additionalHtml))})}},{key:"zoomPanElement",value:function(t,e,o){this.currentImage.style[this.transitionPrefix+"transform"]="translate("+t+","+e+") scale("+o+")"}},{key:"minMax",value:function(t,e,o){return t<e?e:o<t?o:t}},{key:"setZoomData",value:function(t,e,o){this.currentImage.dataset.scale=t,this.currentImage.dataset.translateX=e,this.currentImage.dataset.translateY=o}},{key:"hashchangeHandler",value:function(){this.isOpen&&this.hash===this.initialLocationHash&&(this.hashReseted=!0,this.close())}},{key:"addEvents",value:function(){var o,i=this;this.addEventListener(window,"resize."+this.eventNamespace,function(t){i.isOpen&&i.adjustImage()}),this.addEventListener(this.domNodes.closeButton,["click."+this.eventNamespace,"touchstart."+this.eventNamespace],this.close.bind(this)),this.options.history&&setTimeout(function(){i.addEventListener(window,"hashchange."+i.eventNamespace,function(t){i.isOpen&&i.hashchangeHandler()})},40),this.addEventListener(this.domNodes.navigation.getElementsByTagName("button"),"click."+this.eventNamespace,function(t){return!t.currentTarget.tagName.match(/button/i)||(t.preventDefault(),i.controlCoordinates.swipeDiff=0,void i.loadImage(t.currentTarget.classList.contains("sl-next")?1:-1))}),this.options.scrollZoom&&(o=1,this.addEventListener(this.domNodes.image,["mousewheel","DOMMouseScroll"],function(t){if(i.controlCoordinates.mousedown||i.isAnimating||i.isClosing||!i.isOpen)return!0;0==i.controlCoordinates.containerHeight&&(i.controlCoordinates.containerHeight=i.getDimensions(i.domNodes.image).height,i.controlCoordinates.containerWidth=i.getDimensions(i.domNodes.image).width,i.controlCoordinates.imgHeight=i.getDimensions(i.currentImage).height,i.controlCoordinates.imgWidth=i.getDimensions(i.currentImage).width,i.controlCoordinates.containerOffsetX=i.domNodes.image.offsetLeft,i.controlCoordinates.containerOffsetY=i.domNodes.image.offsetTop,i.controlCoordinates.initialOffsetX=parseFloat(i.currentImage.dataset.translateX),i.controlCoordinates.initialOffsetY=parseFloat(i.currentImage.dataset.translateY)),t.preventDefault();var e=t.delta||t.wheelDelta;void 0===e&&(e=t.detail),e=Math.max(-1,Math.min(1,e)),o+=e*i.options.scrollZoomFactor*o,o=Math.max(1,Math.min(i.options.maxZoom,o)),i.controlCoordinates.targetScale=o;e=document.documentElement.scrollTop||document.body.scrollTop;i.controlCoordinates.pinchOffsetX=t.pageX,i.controlCoordinates.pinchOffsetY=t.pageY-e||0,i.controlCoordinates.limitOffsetX=(i.controlCoordinates.imgWidth*i.controlCoordinates.targetScale-i.controlCoordinates.containerWidth)/2,i.controlCoordinates.limitOffsetY=(i.controlCoordinates.imgHeight*i.controlCoordinates.targetScale-i.controlCoordinates.containerHeight)/2,i.controlCoordinates.scaleDifference=i.controlCoordinates.targetScale-i.controlCoordinates.initialScale,i.controlCoordinates.targetOffsetX=i.controlCoordinates.imgWidth*i.controlCoordinates.targetScale<=i.controlCoordinates.containerWidth?0:i.minMax(i.controlCoordinates.initialOffsetX-(i.controlCoordinates.pinchOffsetX-i.controlCoordinates.containerOffsetX-i.controlCoordinates.containerWidth/2-i.controlCoordinates.initialOffsetX)/(i.controlCoordinates.targetScale-i.controlCoordinates.scaleDifference)*i.controlCoordinates.scaleDifference,-1*i.controlCoordinates.limitOffsetX,i.controlCoordinates.limitOffsetX),i.controlCoordinates.targetOffsetY=i.controlCoordinates.imgHeight*i.controlCoordinates.targetScale<=i.controlCoordinates.containerHeight?0:i.minMax(i.controlCoordinates.initialOffsetY-(i.controlCoordinates.pinchOffsetY-i.controlCoordinates.containerOffsetY-i.controlCoordinates.containerHeight/2-i.controlCoordinates.initialOffsetY)/(i.controlCoordinates.targetScale-i.controlCoordinates.scaleDifference)*i.controlCoordinates.scaleDifference,-1*i.controlCoordinates.limitOffsetY,i.controlCoordinates.limitOffsetY),i.zoomPanElement(i.controlCoordinates.targetOffsetX+"px",i.controlCoordinates.targetOffsetY+"px",i.controlCoordinates.targetScale),1<i.controlCoordinates.targetScale?(i.controlCoordinates.zoomed=!0,(!i.domNodes.caption.style.opacity||0<i.domNodes.caption.style.opacity)&&"none"!==i.domNodes.caption.style.display&&i.fadeOut(i.domNodes.caption,i.options.fadeSpeed)):(1===i.controlCoordinates.initialScale&&(i.controlCoordinates.zoomed=!1,"none"===i.domNodes.caption.style.display&&i.fadeIn(i.domNodes.caption,i.options.fadeSpeed)),i.controlCoordinates.initialPinchDistance=null,i.controlCoordinates.capture=!1),i.controlCoordinates.initialPinchDistance=i.controlCoordinates.targetPinchDistance,i.controlCoordinates.initialScale=i.controlCoordinates.targetScale,i.controlCoordinates.initialOffsetX=i.controlCoordinates.targetOffsetX,i.controlCoordinates.initialOffsetY=i.controlCoordinates.targetOffsetY,i.setZoomData(i.controlCoordinates.targetScale,i.controlCoordinates.targetOffsetX,i.controlCoordinates.targetOffsetY),i.zoomPanElement(i.controlCoordinates.targetOffsetX+"px",i.controlCoordinates.targetOffsetY+"px",i.controlCoordinates.targetScale)})),this.addEventListener(this.domNodes.image,["touchstart."+this.eventNamespace,"mousedown."+this.eventNamespace],function(t){if("A"===t.target.tagName&&"touchstart"===t.type)return!0;if("mousedown"===t.type)t.preventDefault(),i.controlCoordinates.initialPointerOffsetX=t.clientX,i.controlCoordinates.initialPointerOffsetY=t.clientY,i.controlCoordinates.containerHeight=i.getDimensions(i.domNodes.image).height,i.controlCoordinates.containerWidth=i.getDimensions(i.domNodes.image).width,i.controlCoordinates.imgHeight=i.getDimensions(i.currentImage).height,i.controlCoordinates.imgWidth=i.getDimensions(i.currentImage).width,i.controlCoordinates.containerOffsetX=i.domNodes.image.offsetLeft,i.controlCoordinates.containerOffsetY=i.domNodes.image.offsetTop,i.controlCoordinates.initialOffsetX=parseFloat(i.currentImage.dataset.translateX),i.controlCoordinates.initialOffsetY=parseFloat(i.currentImage.dataset.translateY),i.controlCoordinates.capture=!0;else{if(i.controlCoordinates.touchCount=t.touches.length,i.controlCoordinates.initialPointerOffsetX=t.touches[0].clientX,i.controlCoordinates.initialPointerOffsetY=t.touches[0].clientY,i.controlCoordinates.containerHeight=i.getDimensions(i.domNodes.image).height,i.controlCoordinates.containerWidth=i.getDimensions(i.domNodes.image).width,i.controlCoordinates.imgHeight=i.getDimensions(i.currentImage).height,i.controlCoordinates.imgWidth=i.getDimensions(i.currentImage).width,i.controlCoordinates.containerOffsetX=i.domNodes.image.offsetLeft,i.controlCoordinates.containerOffsetY=i.domNodes.image.offsetTop,1===i.controlCoordinates.touchCount){if(i.controlCoordinates.doubleTapped)return i.currentImage.classList.add("sl-transition"),i.controlCoordinates.zoomed?(i.controlCoordinates.initialScale=1,i.setZoomData(i.controlCoordinates.initialScale,0,0),i.zoomPanElement("0px","0px",i.controlCoordinates.initialScale),i.controlCoordinates.zoomed=!1):(i.controlCoordinates.initialScale=i.options.doubleTapZoom,i.setZoomData(i.controlCoordinates.initialScale,0,0),i.zoomPanElement("0px","0px",i.controlCoordinates.initialScale),(!i.domNodes.caption.style.opacity||0<i.domNodes.caption.style.opacity)&&"none"!==i.domNodes.caption.style.display&&i.fadeOut(i.domNodes.caption,i.options.fadeSpeed),i.controlCoordinates.zoomed=!0),setTimeout(function(){i.currentImage&&i.currentImage.classList.remove("sl-transition")},200),!1;i.controlCoordinates.doubleTapped=!0,setTimeout(function(){i.controlCoordinates.doubleTapped=!1},300),i.controlCoordinates.initialOffsetX=parseFloat(i.currentImage.dataset.translateX),i.controlCoordinates.initialOffsetY=parseFloat(i.currentImage.dataset.translateY)}else 2===i.controlCoordinates.touchCount&&(i.controlCoordinates.initialPointerOffsetX2=t.touches[1].clientX,i.controlCoordinates.initialPointerOffsetY2=t.touches[1].clientY,i.controlCoordinates.initialOffsetX=parseFloat(i.currentImage.dataset.translateX),i.controlCoordinates.initialOffsetY=parseFloat(i.currentImage.dataset.translateY),i.controlCoordinates.pinchOffsetX=(i.controlCoordinates.initialPointerOffsetX+i.controlCoordinates.initialPointerOffsetX2)/2,i.controlCoordinates.pinchOffsetY=(i.controlCoordinates.initialPointerOffsetY+i.controlCoordinates.initialPointerOffsetY2)/2,i.controlCoordinates.initialPinchDistance=Math.sqrt((i.controlCoordinates.initialPointerOffsetX-i.controlCoordinates.initialPointerOffsetX2)*(i.controlCoordinates.initialPointerOffsetX-i.controlCoordinates.initialPointerOffsetX2)+(i.controlCoordinates.initialPointerOffsetY-i.controlCoordinates.initialPointerOffsetY2)*(i.controlCoordinates.initialPointerOffsetY-i.controlCoordinates.initialPointerOffsetY2)));i.controlCoordinates.capture=!0}return!!i.controlCoordinates.mousedown||(i.transitionCapable&&(i.controlCoordinates.imageLeft=parseInt(i.domNodes.image.style.left,10)),i.controlCoordinates.mousedown=!0,i.controlCoordinates.swipeDiff=0,i.controlCoordinates.swipeYDiff=0,i.controlCoordinates.swipeStart=t.pageX||t.touches[0].pageX,i.controlCoordinates.swipeYStart=t.pageY||t.touches[0].pageY,!1)}),this.addEventListener(this.domNodes.image,["touchmove."+this.eventNamespace,"mousemove."+this.eventNamespace,"MSPointerMove"],function(t){if(!i.controlCoordinates.mousedown)return!0;if("touchmove"===t.type){if(!1===i.controlCoordinates.capture)return!1;i.controlCoordinates.pointerOffsetX=t.touches[0].clientX,i.controlCoordinates.pointerOffsetY=t.touches[0].clientY,i.controlCoordinates.touchCount=t.touches.length,i.controlCoordinates.touchmoveCount++,1<i.controlCoordinates.touchCount?(i.controlCoordinates.pointerOffsetX2=t.touches[1].clientX,i.controlCoordinates.pointerOffsetY2=t.touches[1].clientY,i.controlCoordinates.targetPinchDistance=Math.sqrt((i.controlCoordinates.pointerOffsetX-i.controlCoordinates.pointerOffsetX2)*(i.controlCoordinates.pointerOffsetX-i.controlCoordinates.pointerOffsetX2)+(i.controlCoordinates.pointerOffsetY-i.controlCoordinates.pointerOffsetY2)*(i.controlCoordinates.pointerOffsetY-i.controlCoordinates.pointerOffsetY2)),null===i.controlCoordinates.initialPinchDistance&&(i.controlCoordinates.initialPinchDistance=i.controlCoordinates.targetPinchDistance),1<=Math.abs(i.controlCoordinates.initialPinchDistance-i.controlCoordinates.targetPinchDistance)&&(i.controlCoordinates.targetScale=i.minMax(i.controlCoordinates.targetPinchDistance/i.controlCoordinates.initialPinchDistance*i.controlCoordinates.initialScale,1,i.options.maxZoom),i.controlCoordinates.limitOffsetX=(i.controlCoordinates.imgWidth*i.controlCoordinates.targetScale-i.controlCoordinates.containerWidth)/2,i.controlCoordinates.limitOffsetY=(i.controlCoordinates.imgHeight*i.controlCoordinates.targetScale-i.controlCoordinates.containerHeight)/2,i.controlCoordinates.scaleDifference=i.controlCoordinates.targetScale-i.controlCoordinates.initialScale,i.controlCoordinates.targetOffsetX=i.controlCoordinates.imgWidth*i.controlCoordinates.targetScale<=i.controlCoordinates.containerWidth?0:i.minMax(i.controlCoordinates.initialOffsetX-(i.controlCoordinates.pinchOffsetX-i.controlCoordinates.containerOffsetX-i.controlCoordinates.containerWidth/2-i.controlCoordinates.initialOffsetX)/(i.controlCoordinates.targetScale-i.controlCoordinates.scaleDifference)*i.controlCoordinates.scaleDifference,-1*i.controlCoordinates.limitOffsetX,i.controlCoordinates.limitOffsetX),i.controlCoordinates.targetOffsetY=i.controlCoordinates.imgHeight*i.controlCoordinates.targetScale<=i.controlCoordinates.containerHeight?0:i.minMax(i.controlCoordinates.initialOffsetY-(i.controlCoordinates.pinchOffsetY-i.controlCoordinates.containerOffsetY-i.controlCoordinates.containerHeight/2-i.controlCoordinates.initialOffsetY)/(i.controlCoordinates.targetScale-i.controlCoordinates.scaleDifference)*i.controlCoordinates.scaleDifference,-1*i.controlCoordinates.limitOffsetY,i.controlCoordinates.limitOffsetY),i.zoomPanElement(i.controlCoordinates.targetOffsetX+"px",i.controlCoordinates.targetOffsetY+"px",i.controlCoordinates.targetScale),1<i.controlCoordinates.targetScale&&(i.controlCoordinates.zoomed=!0,(!i.domNodes.caption.style.opacity||0<i.domNodes.caption.style.opacity)&&"none"!==i.domNodes.caption.style.display&&i.fadeOut(i.domNodes.caption,i.options.fadeSpeed)),i.controlCoordinates.initialPinchDistance=i.controlCoordinates.targetPinchDistance,i.controlCoordinates.initialScale=i.controlCoordinates.targetScale,i.controlCoordinates.initialOffsetX=i.controlCoordinates.targetOffsetX,i.controlCoordinates.initialOffsetY=i.controlCoordinates.targetOffsetY)):(i.controlCoordinates.targetScale=i.controlCoordinates.initialScale,i.controlCoordinates.limitOffsetX=(i.controlCoordinates.imgWidth*i.controlCoordinates.targetScale-i.controlCoordinates.containerWidth)/2,i.controlCoordinates.limitOffsetY=(i.controlCoordinates.imgHeight*i.controlCoordinates.targetScale-i.controlCoordinates.containerHeight)/2,i.controlCoordinates.targetOffsetX=i.controlCoordinates.imgWidth*i.controlCoordinates.targetScale<=i.controlCoordinates.containerWidth?0:i.minMax(i.controlCoordinates.pointerOffsetX-(i.controlCoordinates.initialPointerOffsetX-i.controlCoordinates.initialOffsetX),-1*i.controlCoordinates.limitOffsetX,i.controlCoordinates.limitOffsetX),i.controlCoordinates.targetOffsetY=i.controlCoordinates.imgHeight*i.controlCoordinates.targetScale<=i.controlCoordinates.containerHeight?0:i.minMax(i.controlCoordinates.pointerOffsetY-(i.controlCoordinates.initialPointerOffsetY-i.controlCoordinates.initialOffsetY),-1*i.controlCoordinates.limitOffsetY,i.controlCoordinates.limitOffsetY),Math.abs(i.controlCoordinates.targetOffsetX)===Math.abs(i.controlCoordinates.limitOffsetX)&&(i.controlCoordinates.initialOffsetX=i.controlCoordinates.targetOffsetX,i.controlCoordinates.initialPointerOffsetX=i.controlCoordinates.pointerOffsetX),Math.abs(i.controlCoordinates.targetOffsetY)===Math.abs(i.controlCoordinates.limitOffsetY)&&(i.controlCoordinates.initialOffsetY=i.controlCoordinates.targetOffsetY,i.controlCoordinates.initialPointerOffsetY=i.controlCoordinates.pointerOffsetY),i.setZoomData(i.controlCoordinates.initialScale,i.controlCoordinates.targetOffsetX,i.controlCoordinates.targetOffsetY),i.zoomPanElement(i.controlCoordinates.targetOffsetX+"px",i.controlCoordinates.targetOffsetY+"px",i.controlCoordinates.targetScale))}if("mousemove"===t.type&&i.controlCoordinates.mousedown){if("touchmove"==t.type)return!0;if(t.preventDefault(),!1===i.controlCoordinates.capture)return!1;i.controlCoordinates.pointerOffsetX=t.clientX,i.controlCoordinates.pointerOffsetY=t.clientY,i.controlCoordinates.targetScale=i.controlCoordinates.initialScale,i.controlCoordinates.limitOffsetX=(i.controlCoordinates.imgWidth*i.controlCoordinates.targetScale-i.controlCoordinates.containerWidth)/2,i.controlCoordinates.limitOffsetY=(i.controlCoordinates.imgHeight*i.controlCoordinates.targetScale-i.controlCoordinates.containerHeight)/2,i.controlCoordinates.targetOffsetX=i.controlCoordinates.imgWidth*i.controlCoordinates.targetScale<=i.controlCoordinates.containerWidth?0:i.minMax(i.controlCoordinates.pointerOffsetX-(i.controlCoordinates.initialPointerOffsetX-i.controlCoordinates.initialOffsetX),-1*i.controlCoordinates.limitOffsetX,i.controlCoordinates.limitOffsetX),i.controlCoordinates.targetOffsetY=i.controlCoordinates.imgHeight*i.controlCoordinates.targetScale<=i.controlCoordinates.containerHeight?0:i.minMax(i.controlCoordinates.pointerOffsetY-(i.controlCoordinates.initialPointerOffsetY-i.controlCoordinates.initialOffsetY),-1*i.controlCoordinates.limitOffsetY,i.controlCoordinates.limitOffsetY),Math.abs(i.controlCoordinates.targetOffsetX)===Math.abs(i.controlCoordinates.limitOffsetX)&&(i.controlCoordinates.initialOffsetX=i.controlCoordinates.targetOffsetX,i.controlCoordinates.initialPointerOffsetX=i.controlCoordinates.pointerOffsetX),Math.abs(i.controlCoordinates.targetOffsetY)===Math.abs(i.controlCoordinates.limitOffsetY)&&(i.controlCoordinates.initialOffsetY=i.controlCoordinates.targetOffsetY,i.controlCoordinates.initialPointerOffsetY=i.controlCoordinates.pointerOffsetY),i.setZoomData(i.controlCoordinates.initialScale,i.controlCoordinates.targetOffsetX,i.controlCoordinates.targetOffsetY),i.zoomPanElement(i.controlCoordinates.targetOffsetX+"px",i.controlCoordinates.targetOffsetY+"px",i.controlCoordinates.targetScale)}i.controlCoordinates.zoomed||(i.controlCoordinates.swipeEnd=t.pageX||t.touches[0].pageX,i.controlCoordinates.swipeYEnd=t.pageY||t.touches[0].pageY,i.controlCoordinates.swipeDiff=i.controlCoordinates.swipeStart-i.controlCoordinates.swipeEnd,i.controlCoordinates.swipeYDiff=i.controlCoordinates.swipeYStart-i.controlCoordinates.swipeYEnd,i.options.animationSlide&&i.slide(0,-i.controlCoordinates.swipeDiff+"px"))}),this.addEventListener(this.domNodes.image,["touchend."+this.eventNamespace,"mouseup."+this.eventNamespace,"touchcancel."+this.eventNamespace,"mouseleave."+this.eventNamespace,"pointerup","pointercancel","MSPointerUp","MSPointerCancel"],function(t){i.isTouchDevice&&"touchend"===t.type&&(i.controlCoordinates.touchCount=t.touches.length,0===i.controlCoordinates.touchCount?(i.currentImage&&i.setZoomData(i.controlCoordinates.initialScale,i.controlCoordinates.targetOffsetX,i.controlCoordinates.targetOffsetY),1===i.controlCoordinates.initialScale&&(i.controlCoordinates.zoomed=!1,"none"===i.domNodes.caption.style.display&&i.fadeIn(i.domNodes.caption,i.options.fadeSpeed)),i.controlCoordinates.initialPinchDistance=null,i.controlCoordinates.capture=!1):1===i.controlCoordinates.touchCount?(i.controlCoordinates.initialPointerOffsetX=t.touches[0].clientX,i.controlCoordinates.initialPointerOffsetY=t.touches[0].clientY):1<i.controlCoordinates.touchCount&&(i.controlCoordinates.initialPinchDistance=null)),i.controlCoordinates.mousedown&&(t=!(i.controlCoordinates.mousedown=!1),i.options.loop||(0===i.currentImageIndex&&i.controlCoordinates.swipeDiff<0&&(t=!1),i.currentImageIndex>=i.relatedElements.length-1&&0<i.controlCoordinates.swipeDiff&&(t=!1)),Math.abs(i.controlCoordinates.swipeDiff)>i.options.swipeTolerance&&t?i.loadImage(0<i.controlCoordinates.swipeDiff?1:-1):i.options.animationSlide&&i.slide(i.options.animationSpeed/1e3,"0px"),i.options.swipeClose&&50<Math.abs(i.controlCoordinates.swipeYDiff)&&Math.abs(i.controlCoordinates.swipeDiff)<i.options.swipeTolerance&&i.close())}),this.addEventListener(this.domNodes.image,["dblclick"],function(t){if(!i.isTouchDevice)return i.controlCoordinates.initialPointerOffsetX=t.clientX,i.controlCoordinates.initialPointerOffsetY=t.clientY,i.controlCoordinates.containerHeight=i.getDimensions(i.domNodes.image).height,i.controlCoordinates.containerWidth=i.getDimensions(i.domNodes.image).width,i.controlCoordinates.imgHeight=i.getDimensions(i.currentImage).height,i.controlCoordinates.imgWidth=i.getDimensions(i.currentImage).width,i.controlCoordinates.containerOffsetX=i.domNodes.image.offsetLeft,i.controlCoordinates.containerOffsetY=i.domNodes.image.offsetTop,i.currentImage.classList.add("sl-transition"),i.controlCoordinates.zoomed?(i.controlCoordinates.initialScale=1,i.setZoomData(i.controlCoordinates.initialScale,0,0),i.zoomPanElement("0px","0px",i.controlCoordinates.initialScale),i.controlCoordinates.zoomed=!1,"none"===i.domNodes.caption.style.display&&i.fadeIn(i.domNodes.caption,i.options.fadeSpeed)):(i.controlCoordinates.initialScale=i.options.doubleTapZoom,i.setZoomData(i.controlCoordinates.initialScale,0,0),i.zoomPanElement("0px","0px",i.controlCoordinates.initialScale),(!i.domNodes.caption.style.opacity||0<i.domNodes.caption.style.opacity)&&"none"!==i.domNodes.caption.style.display&&i.fadeOut(i.domNodes.caption,i.options.fadeSpeed),i.controlCoordinates.zoomed=!0),setTimeout(function(){i.currentImage&&(i.currentImage.classList.remove("sl-transition"),i.currentImage.style[i.transitionPrefix+"transform-origin"]=null)},200),!(i.controlCoordinates.capture=!0)})}},{key:"getDimensions",value:function(t){var e=window.getComputedStyle(t),o=t.offsetHeight,i=t.offsetWidth,t=parseFloat(e.borderTopWidth);return{height:o-parseFloat(e.borderBottomWidth)-t-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom),width:i-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth)-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)}}},{key:"updateHash",value:function(){var t="pid="+(this.currentImageIndex+1),e=window.location.href.split("#")[0]+"#"+t;this.hashReseted=!1,this.pushStateSupport?window.history[this.historyHasChanges?"replaceState":"pushState"]("",document.title,e):this.historyHasChanges?window.location.replace(e):window.location.hash=t,this.historyHasChanges||(this.urlChangedOnce=!0),this.historyHasChanges=!0}},{key:"resetHash",value:function(){this.hashReseted=!0,this.urlChangedOnce?history.back():this.pushStateSupport?history.pushState("",document.title,window.location.pathname+window.location.search):window.location.hash="",clearTimeout(this.historyUpdateTimeout)}},{key:"updateURL",value:function(){clearTimeout(this.historyUpdateTimeout),this.historyHasChanges?this.historyUpdateTimeout=setTimeout(this.updateHash.bind(this),800):this.updateHash()}},{key:"setCaption",value:function(t,e){var o=this;this.options.captions&&t&&""!==t&&void 0!==t&&(this.hide(this.domNodes.caption),this.domNodes.caption.style.width=e+"px",this.domNodes.caption.innerHTML=t,this.domNodes.image.appendChild(this.domNodes.caption),setTimeout(function(){o.fadeIn(o.domNodes.caption,o.options.fadeSpeed)},this.options.captionDelay))}},{key:"slide",value:function(t,e){if(!this.transitionCapable)return this.domNodes.image.style.left=e;this.domNodes.image.style[this.transitionPrefix+"transform"]="translateX("+e+")",this.domNodes.image.style[this.transitionPrefix+"transition"]=this.transitionPrefix+"transform "+t+"s linear"}},{key:"getRelated",value:function(e){var t=e&&!1!==e&&"nofollow"!==e?Array.from(this.elements).filter(function(t){return t.getAttribute("rel")===e}):this.elements;return t}},{key:"openImage",value:function(t){var e=this;t.dispatchEvent(new Event("show."+this.eventNamespace)),this.options.disableScroll&&(this.globalScrollbarWidth=this.toggleScrollbar("hide")),this.options.htmlClass&&""!==this.options.htmlClass&&document.querySelector("html").classList.add(this.options.htmlClass),document.body.appendChild(this.domNodes.wrapper),this.domNodes.wrapper.appendChild(this.domNodes.image),this.options.overlay&&document.body.appendChild(this.domNodes.overlay),this.relatedElements=this.getRelated(t.rel),this.options.showCounter&&(1==this.relatedElements.length&&this.domNodes.wrapper.contains(this.domNodes.counter)?this.domNodes.wrapper.removeChild(this.domNodes.counter):1<this.relatedElements.length&&!this.domNodes.wrapper.contains(this.domNodes.counter)&&this.domNodes.wrapper.appendChild(this.domNodes.counter)),this.isAnimating=!0,this.currentImageIndex=this.relatedElements.indexOf(t);var o=t.getAttribute(this.options.sourceAttr);this.currentImage=document.createElement("img"),this.currentImage.style.display="none",this.currentImage.setAttribute("src",o),this.currentImage.dataset.scale=1,this.currentImage.dataset.translateX=0,this.currentImage.dataset.translateY=0,-1===this.loadedImages.indexOf(o)&&this.loadedImages.push(o),this.domNodes.image.innerHTML="",this.domNodes.image.setAttribute("style",""),this.domNodes.image.appendChild(this.currentImage),this.fadeIn(this.domNodes.overlay,this.options.fadeSpeed),this.fadeIn([this.domNodes.counter,this.domNodes.navigation,this.domNodes.closeButton],this.options.fadeSpeed),this.show(this.domNodes.spinner),this.domNodes.counter.querySelector(".sl-current").innerHTML=this.currentImageIndex+1,this.domNodes.counter.querySelector(".sl-total").innerHTML=this.relatedElements.length,this.adjustImage(),this.options.preloading&&this.preload(),setTimeout(function(){t.dispatchEvent(new Event("shown."+e.eventNamespace))},this.options.animationSpeed)}},{key:"forceFocus",value:function(){var e=this;this.removeEventListener(document,"focusin."+this.eventNamespace),this.addEventListener(document,"focusin."+this.eventNamespace,function(t){document===t.target||e.domNodes.wrapper===t.target||e.domNodes.wrapper.contains(t.target)||e.domNodes.wrapper.focus()})}},{key:"addEventListener",value:function(t,e,o,i){t=this.wrap(t),e=this.wrap(e);var n,s=m(t);try{for(s.s();!(n=s.n()).done;){var a=n.value;a.namespaces||(a.namespaces={});var r,l=m(e);try{for(l.s();!(r=l.n()).done;){var d=r.value,c=i||!1;0<=["touchstart","touchmove"].indexOf(d.split(".")[0])&&this.isPassiveEventsSupported&&("object"===h(c)?c.passive=!0:c={passive:!0}),a.namespaces[d]=o,a.addEventListener(d.split(".")[0],o,c)}}catch(t){l.e(t)}finally{l.f()}}}catch(t){s.e(t)}finally{s.f()}}},{key:"removeEventListener",value:function(t,e){t=this.wrap(t),e=this.wrap(e);var o,i=m(t);try{for(i.s();!(o=i.n()).done;){var n,s=o.value,a=m(e);try{for(a.s();!(n=a.n()).done;){var r=n.value;s.namespaces&&s.namespaces[r]&&(s.removeEventListener(r.split(".")[0],s.namespaces[r]),delete s.namespaces[r])}}catch(t){a.e(t)}finally{a.f()}}}catch(t){i.e(t)}finally{i.f()}}},{key:"fadeOut",value:function(r,t,l){var e,d=this,o=m(r=this.wrap(r));try{for(o.s();!(e=o.n()).done;){var i=e.value;i.style.opacity=parseFloat(i)||window.getComputedStyle(i).getPropertyValue("opacity")}}catch(t){o.e(t)}finally{o.f()}this.isFadeIn=!1;var c=16.66666/(t||this.options.fadeSpeed);(function t(){var e=parseFloat(r[0].style.opacity);if((e-=c)<0){var o,i=m(r);try{for(i.s();!(o=i.n()).done;){var n=o.value;n.style.display="none",n.style.opacity=1}}catch(t){i.e(t)}finally{i.f()}l&&l.call(d,r)}else{var s,a=m(r);try{for(a.s();!(s=a.n()).done;)s.value.style.opacity=e}catch(t){a.e(t)}finally{a.f()}requestAnimationFrame(t)}})()}},{key:"fadeIn",value:function(a,t,r,e){var o,l=this,i=m(a=this.wrap(a));try{for(i.s();!(o=i.n()).done;){var n=o.value;n.style.opacity=0,n.style.display=e||"block"}}catch(t){i.e(t)}finally{i.f()}this.isFadeIn=!0;var d=parseFloat(a[0].dataset.opacityTarget||1),c=16.66666*d/(t||this.options.fadeSpeed);(function t(){var e=parseFloat(a[0].style.opacity);if((e+=c)>d){var o,i=m(a);try{for(i.s();!(o=i.n()).done;)o.value.style.opacity=d}catch(t){i.e(t)}finally{i.f()}r&&r.call(l,a)}else{var n,s=m(a);try{for(s.s();!(n=s.n()).done;)n.value.style.opacity=e}catch(t){s.e(t)}finally{s.f()}l.isFadeIn&&requestAnimationFrame(t)}})()}},{key:"hide",value:function(t){var e,o=m(t=this.wrap(t));try{for(o.s();!(e=o.n()).done;){var i=e.value;"none"!=i.style.display&&(i.dataset.initialDisplay=i.style.display),i.style.display="none"}}catch(t){o.e(t)}finally{o.f()}}},{key:"show",value:function(t,e){var o,i=m(t=this.wrap(t));try{for(i.s();!(o=i.n()).done;){var n=o.value;n.style.display=n.dataset.initialDisplay||e||"block"}}catch(t){i.e(t)}finally{i.f()}}},{key:"wrap",value:function(t){return"function"==typeof t[Symbol.iterator]&&"string"!=typeof t?t:[t]}},{key:"on",value:function(t,e){t=this.wrap(t);var o,i=m(this.elements);try{for(i.s();!(o=i.n()).done;){var n=o.value;n.fullyNamespacedEvents||(n.fullyNamespacedEvents={});var s,a=m(t);try{for(a.s();!(s=a.n()).done;){var r=s.value;n.fullyNamespacedEvents[r]=e,n.addEventListener(r,e)}}catch(t){a.e(t)}finally{a.f()}}}catch(t){i.e(t)}finally{i.f()}return this}},{key:"off",value:function(t){t=this.wrap(t);var e,o=m(this.elements);try{for(o.s();!(e=o.n()).done;){var i,n=e.value,s=m(t);try{for(s.s();!(i=s.n()).done;){var a=i.value;void 0!==n.fullyNamespacedEvents&&a in n.fullyNamespacedEvents&&n.removeEventListener(a,n.fullyNamespacedEvents[a])}}catch(t){s.e(t)}finally{s.f()}}}catch(t){o.e(t)}finally{o.f()}return this}},{key:"open",value:function(t){t=t||this.elements[0],"undefined"!=typeof jQuery&&t instanceof jQuery&&(t=t.get(0)),this.initialImageIndex=this.elements.indexOf(t),-1<this.initialImageIndex&&this.openImage(t)}},{key:"next",value:function(){this.loadImage(1)}},{key:"prev",value:function(){this.loadImage(-1)}},{key:"getLighboxData",value:function(){return{currentImageIndex:this.currentImageIndex,currentImage:this.currentImage,globalScrollbarWidth:this.globalScrollbarWidth}}},{key:"destroy",value:function(){this.off(["close."+this.eventNamespace,"closed."+this.eventNamespace,"nextImageLoaded."+this.eventNamespace,"prevImageLoaded."+this.eventNamespace,"change."+this.eventNamespace,"nextDone."+this.eventNamespace,"prevDone."+this.eventNamespace,"error."+this.eventNamespace,"changed."+this.eventNamespace,"next."+this.eventNamespace,"prev."+this.eventNamespace,"show."+this.eventNamespace,"shown."+this.eventNamespace]),this.removeEventListener(this.elements,"click."+this.eventNamespace),this.removeEventListener(document,"focusin."+this.eventNamespace),this.removeEventListener(document.body,"contextmenu."+this.eventNamespace),this.removeEventListener(document.body,"keyup."+this.eventNamespace),this.removeEventListener(this.domNodes.navigation.getElementsByTagName("button"),"click."+this.eventNamespace),this.removeEventListener(this.domNodes.closeButton,"click."+this.eventNamespace),this.removeEventListener(window,"resize."+this.eventNamespace),this.removeEventListener(window,"hashchange."+this.eventNamespace),this.close(),this.isOpen&&(document.body.removeChild(this.domNodes.wrapper),document.body.removeChild(this.domNodes.overlay)),this.elements=null}},{key:"refresh",value:function(){if(!this.initialSelector)throw"refreshing only works when you initialize using a selector!";var t=this.options,e=this.initialSelector;return this.destroy(),this.constructor(e,t),this}}])&&i(t.prototype,e),o&&i(t,o),n}();o.default=t,e.SimpleLightbox=t}.call(this)}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1]);