(function(n){"use strict";typeof define=="function"&&define.amd?define(["./blueimp-helper"],n):(window.blueimp=window.blueimp||{},window.blueimp.Gallery=n(window.blueimp.helper||window.jQuery))})(function(n){"use strict";function t(n,i){if(!n||!n.length||document.body.style.maxHeight===undefined)return null;if(!this||this.options!==t.prototype.options)return new t(n,i);this.list=n,this.num=n.length,this.initOptions(i),this.initialize()}return n.extend(t.prototype,{options:{container:"#blueimp-gallery",slidesContainer:"div",titleElement:"h3",descriptionElement:".description",displayClass:"blueimp-gallery-display",controlsClass:"blueimp-gallery-controls",singleClass:"blueimp-gallery-single",leftEdgeClass:"blueimp-gallery-left",rightEdgeClass:"blueimp-gallery-right",playingClass:"blueimp-gallery-playing",slideClass:"slide",slideLoadingClass:"slide-loading",slideErrorClass:"slide-error",slideContentClass:"slide-content",toggleClass:"toggle",prevClass:"prev",nextClass:"next",closeClass:"close",playPauseClass:"play-pause",typeProperty:"type",titleProperty:"title",descriptionProperty:"data-description",urlProperty:"href",displayTransition:!0,clearSlides:!0,stretchImages:!1,toggleControlsOnReturn:!0,toggleSlideshowOnSpace:!0,enableKeyboardNavigation:!0,closeOnEscape:!0,closeOnSlideClick:!0,closeOnSwipeUpOrDown:!0,emulateTouchEvents:!0,hidePageScrollbars:!0,disableScroll:!0,carousel:!1,continuous:!0,unloadElements:!0,startSlideshow:!1,slideshowInterval:5e3,index:0,preloadRange:2,transitionSpeed:400,slideshowTransitionSpeed:undefined,event:undefined,onopen:undefined,onopened:undefined,onslide:undefined,onslideend:undefined,onslidecomplete:undefined,onclose:undefined,onclosed:undefined},carouselOptions:{hidePageScrollbars:!1,toggleControlsOnReturn:!1,toggleSlideshowOnSpace:!1,enableKeyboardNavigation:!1,closeOnEscape:!1,closeOnSlideClick:!1,closeOnSwipeUpOrDown:!1,disableScroll:!1,startSlideshow:!0},support:function(t){var i={touch:window.ontouchstart!==undefined||window.DocumentTouch&&document instanceof DocumentTouch},r=function(){var n=i.transition,r,u;document.body.appendChild(t),n&&(r=n.name.slice(0,-9)+"ransform",t.style[r]!==undefined&&(t.style[r]="translateZ(0)",u=window.getComputedStyle(t).getPropertyValue(n.prefix+"transform"),i.transform={prefix:n.prefix,name:r,translate:!0,translateZ:!!u&&u!=="none"})),t.style.backgroundSize!==undefined&&(i.backgroundSize={},t.style.backgroundSize="contain",i.backgroundSize.contain=window.getComputedStyle(t).getPropertyValue("background-size")==="contain",t.style.backgroundSize="cover",i.backgroundSize.cover=window.getComputedStyle(t).getPropertyValue("background-size")==="cover"),document.body.removeChild(t)};if(function(n,i){var r;for(r in i)if(i.hasOwnProperty(r)&&t.style[r]!==undefined){n.transition=i[r],n.transition.name=r;break}}(i,{webkitTransition:{end:"webkitTransitionEnd",prefix:"-webkit-"},MozTransition:{end:"transitionend",prefix:"-moz-"},OTransition:{end:"otransitionend",prefix:"-o-"},transition:{end:"transitionend",prefix:""}}),document.body)r();else n(document).on("DOMContentLoaded",r);return i}(document.createElement("div")),requestAnimationFrame:window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame,initialize:function(){if(this.initStartIndex(),this.initWidget()===!1)return!1;this.initEventListeners();this.onslide(this.index);this.ontransitionend(),this.options.startSlideshow&&this.play()},slide:function(n,t){window.clearTimeout(this.timeout);var r=this.index,i,f,u;if(r!==n&&this.num!==1){if(t||(t=this.options.transitionSpeed),this.support.transition){for(this.options.continuous||(n=this.circle(n)),i=Math.abs(r-n)/(r-n),this.options.continuous&&(f=i,i=-this.positions[this.circle(n)]/this.slideWidth,i!==f&&(n=-i*this.num+n)),u=Math.abs(r-n)-1;u;)u-=1,this.move(this.circle((n>r?n:r)-u-1),this.slideWidth*i,0);n=this.circle(n),this.move(r,this.slideWidth*i,t),this.move(n,0,t),this.options.continuous&&this.move(this.circle(n-i),-(this.slideWidth*i),0)}else n=this.circle(n),this.animate(r*-this.slideWidth,n*-this.slideWidth,t);this.onslide(n)}},getIndex:function(){return this.index},getNumber:function(){return this.num},prev:function(){(this.options.continuous||this.index)&&this.slide(this.index-1)},next:function(){(this.options.continuous||this.index1&&(this.timeout=this.setTimeout(!this.requestAnimationFrame&&this.slide||function(n,i){t.animationFrameId=t.requestAnimationFrame.call(window,function(){t.slide(n,i)})},[this.index+1,this.options.slideshowTransitionSpeed],this.interval)),this.container.addClass(this.options.playingClass)},pause:function(){window.clearTimeout(this.timeout),this.interval=null,this.container.removeClass(this.options.playingClass)},add:function(n){var t;for(n.concat||(n=Array.prototype.slice.call(n)),this.list.concat||(this.list=Array.prototype.slice.call(this.list)),this.list=this.list.concat(n),this.num=this.list.length,this.num>2&&this.options.continuous===null&&(this.options.continuous=!0,this.container.removeClass(this.options.leftEdgeClass)),this.container.removeClass(this.options.rightEdgeClass).removeClass(this.options.singleClass),t=this.num-n.length;ti){r.slidesContainer[0].style.left=t+"px",r.ontransitionend(),window.clearInterval(f);return}r.slidesContainer[0].style.left=(t-n)*(Math.floor(e/i*100)/100)+n+"px"},4)},preventDefault:function(n){n.preventDefault?n.preventDefault():n.returnValue=!1},onresize:function(){this.initSlides(!0)},onmousedown:function(n){if(n.which&&n.which===1&&n.target.nodeName!=="VIDEO"){(n.originalEvent||n).touches=[{pageX:n.pageX,pageY:n.pageY}];this.ontouchstart(n)}},onmousemove:function(n){if(this.touchStart){(n.originalEvent||n).touches=[{pageX:n.pageX,pageY:n.pageY}];this.ontouchmove(n)}},onmouseup:function(n){if(this.touchStart){this.ontouchend(n);delete this.touchStart}},onmouseout:function(t){if(this.touchStart){var r=t.target,i=t.relatedTarget;if(!i||i!==r&&!n.contains(r,i))this.onmouseup(t)}},ontouchstart:function(n){var t=(n.originalEvent||n).touches[0];this.touchStart={x:t.pageX,y:t.pageY,time:Date.now()},this.isScrolling=undefined,this.touchDelta={}},ontouchmove:function(n){var u=(n.originalEvent||n).touches[0],f=(n.originalEvent||n).scale,t=this.index,i,r;if(!(u.length>1)&&(!f||f===1))if(this.options.disableScroll&&n.preventDefault(),this.touchDelta={x:u.pageX-this.touchStart.x,y:u.pageY-this.touchStart.y},i=this.touchDelta.x,this.isScrolling===undefined&&(this.isScrolling=this.isScrolling||Math.abs(i)0||t===this.num-1&&i<0?Math.abs(i)/this.slideWidth+1:1),r=[t],t&&r.push(t-1),t20||Math.abs(this.touchDelta.x)>i/2,h=!n&&this.touchDelta.x>0||n===this.num-1&&this.touchDelta.x<0,l=!s&&this.options.closeOnSwipeUpOrDown&&(o&&Math.abs(this.touchDelta.y)>20||Math.abs(this.touchDelta.y)>this.slideHeight/2),r,u,e,f,c;if(this.options.continuous&&(h=!1),r=this.touchDelta.x<0?-1:1,this.isScrolling)l?this.close():this.translateY(n,0,t);else if(s&&!h){u=n+r,e=n-r,f=i*r,c=-i*r,this.options.continuous?(this.move(this.circle(u),f,0),this.move(this.circle(n-2*r),c,0)):u>=0&&uthis.container[0].clientHeight&&(r.style.maxHeight=this.container[0].clientHeight),this.interval&&this.slides[this.index]===i&&this.play(),this.setTimeout(this.options.onslidecomplete,[u,i]))},onload:function(n){this.oncomplete(n)},onerror:function(n){this.oncomplete(n)},onkeydown:function(n){switch(n.which||n.keyCode){case 13:this.options.toggleControlsOnReturn&&(this.preventDefault(n),this.toggleControls());break;case 27:this.options.closeOnEscape&&this.close();break;case 32:this.options.toggleSlideshowOnSpace&&(this.preventDefault(n),this.toggleSlideshow());break;case 37:this.options.enableKeyboardNavigation&&(this.preventDefault(n),this.prev());break;case 39:this.options.enableKeyboardNavigation&&(this.preventDefault(n),this.next())}},handleClick:function(t){var i=this.options,f=t.target||t.srcElement,u=f.parentNode,r=function(t){return n(f).hasClass(t)||n(u).hasClass(t)};r(i.toggleClass)?(this.preventDefault(t),this.toggleControls()):r(i.prevClass)?(this.preventDefault(t),this.prev()):r(i.nextClass)?(this.preventDefault(t),this.next()):r(i.closeClass)?(this.preventDefault(t),this.close()):r(i.playPauseClass)?(this.preventDefault(t),this.toggleSlideshow()):u===this.slidesContainer[0]?(this.preventDefault(t),i.closeOnSlideClick?this.close():this.toggleControls()):u.parentNode&&u.parentNode===this.slidesContainer[0]&&(this.preventDefault(t),this.toggleControls())},onclick:function(n){if(this.options.emulateTouchEvents&&this.touchDelta&&(Math.abs(this.touchDelta.x)>20||Math.abs(this.touchDelta.y)>20)){delete this.touchDelta;return}return this.handleClick(n)},updateEdgeClasses:function(n){n?this.container.removeClass(this.options.leftEdgeClass):this.container.addClass(this.options.leftEdgeClass),n===this.num-1?this.container.addClass(this.options.rightEdgeClass):this.container.removeClass(this.options.rightEdgeClass)},handleSlide:function(n){this.options.continuous||this.updateEdgeClasses(n),this.loadElements(n),this.options.unloadElements&&this.unloadElements(n),this.setTitle(n),this.setDescription(n)},onslide:function(n){this.index=n,this.handleSlide(n),this.setTimeout(this.options.onslide,[n,this.slides[n]])},setDescription:function(t){var i=n(this.list[t]).data("description"),r=this.descriptionElement;r.length&&(this.descriptionElement.empty(),this.descriptionElement.parent().hide(),i&&(r[0].appendChild(document.createTextNode(i)),this.descriptionElement.parent().show()))},setTitle:function(n){var t=this.slides[n].firstChild.title,i=this.titleElement;i.length&&(this.titleElement.empty(),t&&i[0].appendChild(document.createTextNode(t)))},setTimeout:function(n,t,i){var r=this;return n&&window.setTimeout(function(){n.apply(r,t||[])},i||0)},imageFactory:function(t,i){var l=this,f=this.imagePrototype.cloneNode(!1),e=t,u=this.options.stretchImages,c,r,o=function(t){if(!c){if(t={type:t.type,target:r},!r.parentNode)return l.setTimeout(o,[t]);c=!0,n(f).off("load error",o),u&&t.type==="load"&&(r.style.background='url("'+e+'") center no-repeat',r.style.backgroundSize=u),i(t)}},s,h;typeof e!="string"&&(e=this.getItemProperty(t,this.options.urlProperty),s=this.getItemProperty(t,this.options.titleProperty),h=this.getItemProperty(t,this.options.descriptionProperty)),u===!0&&(u="contain"),u=this.support.backgroundSize&&this.support.backgroundSize[u]&&u,u?r=this.elementPrototype.cloneNode(!1):(r=f,f.draggable=!1),s&&(r.title=s),h&&(r.description=h);n(f).on("load error",o);return f.src=e,r},createElement:function(t,i){var u=t&&this.getItemProperty(t,this.options.typeProperty),f=u&&this[u.split("/")[0]+"Factory"]||this.imageFactory,r=t&&f.call(this,t,i);return r||(r=this.elementPrototype.cloneNode(!1),this.setTimeout(i,[{type:"error",target:r}])),n(r).addClass(this.options.slideContentClass),r},loadElement:function(t){this.elements[t]||(this.slides[t].firstChild?this.elements[t]=n(this.slides[t]).hasClass(this.options.slideErrorClass)?3:2:(this.elements[t]=1,n(this.slides[t]).addClass(this.options.slideLoadingClass),this.slides[t].appendChild(this.createElement(this.list[t],this.proxyListener))))},loadElements:function(n){for(var r=Math.min(this.num,this.options.preloadRange*2+1),i=n,t=0;tthis.options.preloadRange&&r+this.options.preloadRangen?-this.slideWidth:this.index