!function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.PhotoSwipe=t()}(this,function(){"use strict";return function(p,Z,t,z){function e(){return{x:0,y:0}}function N(e,t){g.extend(x,t.publicMethods),Ye.push(e)}function U(e){var t=A();return t-1t.min[e]?n[e]=t.min[e]:n[e]=pt&&(Ae=0x.currItem.fitRatio&&Wt(Ce))}}var V,X,j,m,$,J,Q,ee,o,f,te,ne,oe,ie,ae,r,re,le,se,ue,ce,de,pe,i,me,fe,he,ge,xe,ye,l,we,ve,be,Ce,Ie,Te,Ee,s,De,Se,_e,Me,Fe,u,c,Oe,d,ke,h,Ae,Re,Le,Pe,Ze,ze,g={features:null,bind:function(e,t,n,o){var i=(o?"remove":"add")+"EventListener";t=t.split(" ");for(var a=0;ax.currItem.fitRatio?qe||(un(x.currItem,!1,!0),qe=!0):qe&&(un(x.currItem),qe=!1)),Xe(ke,w.x,w.y,f))},je=function(e){e.container&&Xe(e.container.style,e.initialPosition.x,e.initialPosition.y,e.initialZoomLevel,e)},$e=function(e,t){t[de]=ne+e+"px, 0px"+oe},Je=function(e,t){var n;!y.loop&&t&&(t=m+(b.x*He-e)/b.x,n=Math.round(e-k.x),t<0&&0=A()-1&&n<0)&&(e=k.x+n*y.mainScrollEndFriction),k.x=e,$e(e,$)},Qe=function(e,t){var n=Ct[e]-We[e];return Ke[e]+Ue[e]+n-t/te*n},S=function(e,t){e.x=t.x,e.y=t.y,t.id&&(e.id=t.id)},et=function(e){e.x=Math.round(e.x),e.y=Math.round(e.y)},tt=null,nt=function(){tt&&(g.unbind(document,"mousemove",nt),g.addClass(p,"pswp--has_mouse"),y.mouseUsed=!0,I("mouseUsed")),tt=setTimeout(function(){tt=null},100)},ot=function(e,t){e=ln(x.currItem,v,e);return t&&(d=e),e},it=function(e){return(e=e||x.currItem).initialZoomLevel},at=function(e){return 0<(e=e||x.currItem).w?y.maxSpreadZoom:1},_={},rt=0,lt=function(e){_[e]&&(_[e].raf&&fe(_[e].raf),rt--,delete _[e])},st=function(e){_[e]&<(e),_[e]||(rt++,_[e]={})},ut=function(){for(var e in _)_.hasOwnProperty(e)&<(e)},ct=function(e,t,n,o,i,a,r){function l(){_[e]&&(s=T()-u,o<=s?(lt(e),a(n),r&&r()):(a((n-t)*i(s/o)+t),_[e].raf=me(l)))}var s,u=T();st(e);l()},z={shout:I,listen:a,viewportSize:v,options:y,isMainScrollAnimating:function(){return h},getZoomLevel:function(){return f},getCurrentIndex:function(){return m},isDragging:function(){return s},isZooming:function(){return c},setScrollOffset:function(e,t){We.x=e,ye=We.y=t,I("updateScrollOffset",We)},applyZoomPan:function(e,t,n,o){w.x=t,w.y=n,f=e,D(o)},init:function(){if(!V&&!X){x.framework=g,x.template=p,x.bg=g.getChildByClass(p,"pswp__bg"),he=p.className,V=!0,l=g.detectFeatures(),me=l.raf,fe=l.caf,de=l.transform,xe=l.oldIE,x.scrollWrap=g.getChildByClass(p,"pswp__scroll-wrap"),x.container=g.getChildByClass(x.scrollWrap,"pswp__container"),$=x.container.style,x.itemHolders=r=[{el:x.container.children[0],wrap:0,index:-1},{el:x.container.children[1],wrap:0,index:-1},{el:x.container.children[2],wrap:0,index:-1}],r[0].el.style.display=r[2].el.style.display="none",de?(t=l.perspective&&!i,ne="translate"+(t?"3d(":"("),oe=l.perspective?", 0px)":")"):(de="left",g.addClass(p,"pswp--ie"),$e=function(e,t){t.left=e+"px"},je=function(e){var t=1=A())&&(m=0),x.currItem=en(m),(l.isOldIOSPhone||l.isOldAndroid)&&(Be=!1),p.setAttribute("aria-hidden","false"),y.modal&&(Be?p.style.position="fixed":(p.style.position="absolute",p.style.top=g.getScrollY()+"px")),void 0===ye&&(I("initialLayout"),ye=ge=g.getScrollY());var n="pswp--open ";for(y.mainClass&&(n+=y.mainClass+" "),y.showHideOpacity&&(n+="pswp--animate_opacity "),n=(n=(n+=i?"pswp--touch":"pswp--notouch")+(l.animationName?" pswp--css_animation":""))+(l.svg?" pswp--svg":""),g.addClass(p,n),x.updateSize(),J=-1,C=null,e=0;e<3;e++)$e((e+J)*b.x,r[e].el.style);xe||g.bind(x.scrollWrap,ee,x),a("initialZoomInEnd",function(){x.setContent(r[0],m-1),x.setContent(r[2],m+1),r[0].el.style.display=r[2].el.style.display="block",y.focus&&p.focus(),g.bind(document,"keydown",x),l.transform&&g.bind(x.scrollWrap,"click",x),y.mouseUsed||g.bind(document,"mousemove",nt),g.bind(window,"resize scroll orientationchange",x),I("bindEvents")}),x.setContent(r[1],m),x.updateCurrItem(),I("afterInit"),Be||(ie=setInterval(function(){rt||s||c||f!==x.currItem.initialZoomLevel||x.updateSize()},1e3)),g.addClass(p,"pswp--visible")}},close:function(){V&&(X=!(V=!1),I("close"),g.unbind(window,"resize scroll orientationchange",x),g.unbind(window,"scroll",o.scroll),g.unbind(document,"keydown",x),g.unbind(document,"mousemove",nt),l.transform&&g.unbind(x.scrollWrap,"click",x),s&&g.unbind(window,Q,x),clearTimeout(we),I("unbindEvents"),tn(x.currItem,null,!0,x.destroy))},destroy:function(){I("destroy"),jt&&clearTimeout(jt),p.setAttribute("aria-hidden","true"),p.className=he,ie&&clearInterval(ie),g.unbind(x.scrollWrap,ee,x),g.unbind(window,"scroll",x),Dt(),ut(),Ve=null},panTo:function(e,t,n){n||(e>d.min.x?e=d.min.x:ed.min.y?t=d.min.y:td.min[e]||ad.min[e]&&(u=y.panEndFriction,d.min[e],n=d.min[e]-Ke[e]),(n<=0||s<0)&&1gt.x&&(i=gt.x)):d.min.x!==d.max.x&&(o=a)):(ax.currItem.fitRatio&&(w[e]+=t[e]*u)},Kt=function(){if(u){var e,t,n,o,i,a=u.length;if(0!==a)if(S(M,u[0]),F.x=M.x-O.x,F.y=M.y-O.y,c&&1x.currItem.initialZoomLevel+x.currItem.initialZoomLevel/15&&(Ze=!0),t=1,n=it(),o=at(),e=pt&&(F.x-=u[0].x-ft.x),Math.abs(F.y)>=pt)&&(F.y-=u[0].y-ft.y),O.x=M.x,O.y=M.y,0!==F.x||0!==F.y)){if("v"===Ae&&y.closeOnVerticalDrag)if(!_t())return Ue.y+=F.y,w.y+=F.y,i=Lt(),Te=!0,I("onVerticalDrag",i),E(i),void D();Rt(T(),M.x,M.y),_e=!0,d=x.currItem.bounds,Ut("x",F)||(Ut("y",F),et(w),D())}}},Ht=function(){var t,n,o={lastFlickOffset:{},lastFlickDist:{},lastFlickSpeed:{},slowDownRatio:{},slowDownRatioReverse:{},speedDecelerationRatio:{},speedDecelerationRatioAbs:{},distanceOffset:{},backAnimDestination:{},backAnimStarted:{},calculateSwipeSpeed:function(e){n=(1d.min[t]?o.backAnimDestination[t]=d.min[t]:w[t]=A()&&(m=y.loop?0:A()-1,i=!0),i&&!y.loop||(C+=o,He-=o,n=!0));var n,o,i,e=b.x*He,a=Math.abs(e-k.x),r=n||e>k.x==0The image could not be loaded.',forceProgressiveLoading:!1,preload:[1,1],getNumItemsFn:function(){return $t.length}},an=function(){return{center:{x:0,y:0},max:{x:0,y:0},min:{x:0,y:0}}},rn=function(e,t,n){var o=e.bounds;o.center.x=Math.round((R.x-t)/2),o.center.y=Math.round((R.y-n)/2)+e.vGap.top,o.max.x=t>R.x?Math.round(R.x-t):o.center.x,o.max.y=n>R.y?Math.round(R.y-n)+e.vGap.top:o.center.y,o.min.x=t>R.x?0:o.center.x,o.min.y=n>R.y?e.vGap.top:o.center.y},ln=function(e,t,n){var o,i;return!e.src||e.loadError?(e.w=e.h=0,e.initialZoomLevel=e.fitRatio=1,e.bounds=an(),e.initialPosition=e.bounds.center,e.bounds):((o=!n)&&(e.vGap||(e.vGap={top:0,bottom:0}),I("parseVerticalMargin",e)),R.x=t.x,R.y=t.y-e.vGap.top-e.vGap.bottom,o&&(t=R.x/e.w,i=R.y/e.h,e.fitRatio=t=d.max.x&&n<=d.min.y&&n>=d.max.y)&&e.preventDefault(),x.panTo(t,n)},toggleDesktopZoom:function(e){e=e||{x:v.x/2+We.x,y:v.y/2+We.y};var t=y.getDoubleTapZoom(!0,x.currItem),n=f===t;x.mouseZoomedIn=!n,x.zoomTo(n?x.currItem.initialZoomLevel:t,e,333),g[(n?"remove":"add")+"Class"](p,"pswp--zoomed-in")}}}),{history:!0,galleryUID:1}),Dn=function(){return P.hash.substring(1)},Sn=function(){var e,t;gn&&clearTimeout(gn),rt||s?gn=setTimeout(Sn,500):(xn?clearTimeout(hn):xn=!0,t=m+1,(e=en(m)).hasOwnProperty("pid")&&(t=e.pid),e=n+"&gid="+y.galleryUID+"&pid="+t,vn||-1===P.hash.indexOf(e)&&(Cn=!0),t=P.href.split("#")[0]+"#"+e,In?"#"+e!==window.location.hash&&history[vn?"replaceState":"pushState"]("",document.title,t):vn?P.replace(t):P.hash=e,vn=!0,hn=setTimeout(function(){xn=!1},60))};N("History",{publicMethods:{initHistory:function(){var e,t;g.extend(y,En,!0),y.history&&(P=window.location,vn=bn=Cn=!1,n=Dn(),In="pushState"in history,-1"+e.label+"";if(E.parseShareButtonOut)i=E.parseShareButtonOut(e,i)}x.children[0].innerHTML=i,x.children[0].onclick=z}}function a(e){for(var t=0;tE.fitControlsWidth?(t=E.barsSize,E.captionEl&&"auto"===t.bottom?(h||((h=l.createEl("pswp__caption pswp__caption--fake")).appendChild(l.createEl("pswp__caption__center")),m.insertBefore(h,f),l.addClass(m,"pswp__ui--fit")),E.addCaptionHTMLFn(e,h,!0)?(e=h.clientHeight,n.bottom=parseInt(e,10)||44):n.bottom=t.top):n.bottom="auto"===t.bottom?0:t.bottom,n.top=t.top):n.top=n.bottom=0}function P(){function e(e){if(e)for(var t=e.length,n=0;n