text: /*! PhotoSwipe - v4.0.0 - 2014-12-08
  * http://photoswipe.com
  * Copyright (c) 2014 Dmitry Semenov; */
  (function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t:e.PhotoSwipe=t()})(this,function(){"use strict";var e=function(e,t,n,i){var o={features:null,bind:function(e,t,n,i){var o=(i?"remove":"add")+"EventListener";t=t.split(" ");for(var a=0;t.length>a;a++)t[a]&&e[o](t[a],n,!1)},isArray:function(e){return e instanceof Array},createEl:function(e,t){var n=document.createElement(t||"div");return e&&(n.className=e),n},getScrollY:function(){var e=window.pageYOffset;return void 0!==e?e:document.documentElement.scrollTop},unbind:function(e,t,n){o.bind(e,t,n,!0)},removeClass:function(e,t){var n=RegExp("(\\s|^)"+t+"(\\s|$)");e.className=e.className.replace(n," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")},addClass:function(e,t){o.hasClass(e,t)||(e.className+=(e.className?" ":"")+t)},hasClass:function(e,t){return e.className&&RegExp("(^|\\s)"+t+"(\\s|$)").test(e.className)},arraySearch:function(e,t,n){for(var i=e.length;i--;)if(e[i][n]===t)return i;return-1},extend:function(e,t,n){for(var i in t)if(t.hasOwnProperty(i)){if(n&&e.hasOwnProperty(i))continue;e[i]=t[i]}},easing:{sine:{out:function(e){return Math.sin(e*(Math.PI/2))},inOut:function(e){return-(Math.cos(Math.PI*e)-1)/2}},cubic:{out:function(e){return--e*e*e+1}}},detectFeatures:function(){if(o.features)return o.features;var e=o.createEl(),t=e.style,n="",i={};if(i.oldIE=document.all&&!document.addEventListener,i.touch="ontouchstart"in window,window.requestAnimationFrame&&(i.raf=window.requestAnimationFrame,i.caf=window.cancelAnimationFrame),i.pointerEvent=navigator.pointerEnabled||navigator.msPointerEnabled,!i.pointerEvent){var a=navigator.userAgent;if(/iP(hone|od)/.test(navigator.platform)){var r=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);r=parseInt(r[1],10),r>=1&&8>r&&(i.isOldIOSPhone=!0)}var l=a.match(/Android\s([0-9\.]*)/),s=l?l[1]:0;s=parseFloat(s),s>=1&&4.4>s?i.isOldAndroid=!0:s>=5&&(i.isNewAndroid=!0),i.isMobileOpera=/opera mini|opera mobi/i.test(a)}for(var u,c,d=["transform","perspective","animationName"],m=["","webkit","Moz","ms","O"],p=0;4>p;p++){n=m[p];for(var f=0;3>f;f++)u=d[f],c=n+(n?u.charAt(0).toUpperCase()+u.slice(1):u),!i[u]&&c in t&&(i[u]=c);n&&!i.raf&&(n=n.toLowerCase(),i.raf=window[n+"RequestAnimationFrame"],i.raf&&(i.caf=window[n+"CancelAnimationFrame"]||window[n+"CancelRequestAnimationFrame"]))}if(!i.raf){var h=0;i.raf=function(e){var t=(new Date).getTime(),n=Math.max(0,16-(t-h)),i=window.setTimeout(function(){e(t+n)},n);return h=t+n,i},i.caf=function(e){clearTimeout(e)}}return i.svg=!!document.createElementNS&&!!document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,o.features=i,i}};o.detectFeatures(),o.features.oldIE&&(o.bind=function(e,t,n,i){t=t.split(" ");for(var o,a=(i?"detach":"attach")+"Event",r=function(){n.handleEvent.call(n)},l=0;t.length>l;l++)if(o=t[l])if("object"==typeof n&&n.handleEvent){if(i){if(!n["oldIE"+o])return!1}else n["oldIE"+o]=r;e[a]("on"+o,n["oldIE"+o])}else e[a]("on"+o,n)});var a=this,r=25,l=3,s={allowPanToNext:!0,spacing:.12,bgOpacity:1,mouseUsed:!1,loop:!0,pinchToClose:!0,closeOnScroll:!0,closeOnVerticalDrag:!0,hideAnimationDuration:333,showAnimationDuration:333,showHideOpacity:!1,focus:!0,escKey:!0,arrowKeys:!0,mainScrollEndFriction:.35,panEndFriction:.35,scaleMode:"fit",modal:!0,alwaysFadeIn:!1};o.extend(s,i);var u,c,d,m,p,f,h,y,v,x,g,w,b,I,D,C,T,M,Z,k,S,A,O,E,R,F,P,L,z,N,_,U,H,Y,B,W,V,G,X,q,K,$,j,J,Q,et,tt,nt,it,ot,at,rt,lt,st,ut,ct,dt,mt,pt,ft,ht,yt,vt,xt=function(){return{x:0,y:0}},gt=0,wt=xt(),bt=xt(),It=xt(),Dt=xt(),Ct={},Tt=0,Mt=0,Zt=xt(),kt=0,St=!0,At=[],Ot={},Et=function(e,t){o.extend(a,t.publicMethods),At.push(e)},Rt=function(e){var t=yt();return e>t-1?e-t:0>e?t+e:e},Ft={},Pt=function(e,t){return Ft[e]||(Ft[e]=[]),Ft[e].push(t)},Lt=function(e){var t=Ft[e];if(t){var n=Array.prototype.slice.call(arguments);n.shift();for(var i=0;t.length>i;i++)t[i].apply(a,n)}},zt=function(){return(new Date).getTime()},Nt=function(e){ut=e,a.bg.style.opacity=e*s.bgOpacity},_t=function(e,t,n,i){e[A]=w+t+"px, "+n+"px"+b+" scale("+i+")"},Ut=function(){it&&_t(it,It.x,It.y,x)},Ht=function(e){_t(e.container.style,e.initialPosition.x,e.initialPosition.y,e.initialZoomLevel)},Yt=function(e,t){t[A]=w+e+"px, 0px"+b},Bt=function(e,t){if(!s.loop&&t){var n=m+(Zt.x*Tt-e)/Zt.x,i=Math.round(e-bn.x);(0>n&&i>0||n>=yt()-1&&0>i)&&(e=bn.x+i*s.mainScrollEndFriction)}bn.x=e,Yt(e,p)},Wt=function(e){return 1/tt*e*g},Vt=function(e,t){var n=In[e]-rt[e];return bt[e]+wt[e]+n-n*(t/g)},Gt=function(e,t){return e.x===t.x&&e.y===t.y},Xt=function(e,t){return r>Math.abs(e.x-t.x)&&r>Math.abs(e.y-t.y)},qt=function(e,t){e.x=t.x,e.y=t.y,t.id&&(e.id=t.id)},Kt=function(){o.bind(document,"keydown keyup",a),s.mouseUsed||o.bind(document,"mousemove",Jt),o.bind(window,"resize scroll",a),Lt("bindEvents")},$t=function(){o.unbind(window,"resize",a),o.unbind(window,"scroll",v.scroll),o.unbind(document,"keydown keyup",a),o.unbind(document,"mousemove",Jt),G&&o.unbind(window,h,a),Lt("unbindEvents")},jt=null,Jt=function(){jt&&(o.unbind(document,"mousemove",Jt),o.addClass(e,"pswp--has_mouse"),s.mouseUsed=!0,Lt("mouseUsed")),jt=setTimeout(function(){jt=null},100)},Qt=function(e,t){var n=jn(a.currItem,Ct,e);return t&&(nt=n),n},en=function(e,t,n,i){return i===a.currItem.initialZoomLevel?(n[e]=a.currItem.initialPosition[e],!0):(n[e]=Vt(e,i),n[e]>t.min[e]?(n[e]=t.min[e],!0):n[e]<t.max[e]?(n[e]=t.max[e],!0):!1)},tn={},nn=0,on=function(e){tn[e]&&(tn[e].raf&&F(tn[e].raf),nn--,delete tn[e])},an=function(e){tn[e]&&on(e),tn[e]||(nn++,tn[e]={})},rn=function(){for(var e in tn)tn.hasOwnProperty(e)&&on(e)},ln=function(e,t,n,i,o,a,r){var l,s=zt();an(e);var u=function(){if(tn[e]){if(l=zt()-s,l>=i)return on(e),a(n),r&&r(),void 0;a((n-t)*o(l/i)+t),tn[e].raf=R(u)}};u()},sn=function(t,n,i,a){U&&clearTimeout(U),ft=!0,pt=!0;var r;t.initialLayout?(r=t.initialLayout,t.initialLayout=null):r=s.getThumbBoundsFn&&s.getThumbBoundsFn(m);var l=function(){on("initialZoom"),i||(Nt(1),n&&(n.style.display="block"),o.addClass(e,"pswp--animated-in"),Lt("initialZoom"+(i?"OutEnd":"InEnd"))),a&&a(),ft=!1},u=i?s.hideAnimationDuration:s.showAnimationDuration;return r&&void 0!==r.x&&u?(t.miniImg&&(t.miniImg.style.webkitBackfaceVisibility="hidden"),i||(x=r.w/t.w,It.x=r.x,It.y=r.y-L,s.showHideOpacity&&(e.style.opacity=.001,e.style.webkitBackfaceVisibility="hidden"),Ut()),an("initialZoom"),i&&!d&&o.removeClass(e,"pswp--animated-in"),U=setTimeout(function(){if(Lt("initialZoom"+(i?"Out":"In")),i){var n=r.w/t.w,a={x:It.x,y:It.y},c=x,m=L,p=ut,f=function(t){D&&(m=o.getScrollY(),D=!1),1===t?(x=n,It.x=r.x,It.y=r.y-m,d&&l()):(x=(n-c)*t+c,It.x=(r.x-a.x)*t+a.x,It.y=(r.y-m-a.y)*t+a.y),Ut(),s.showHideOpacity?e.style.opacity=1-t:Nt(p-t*p)};d?ln("initialZoom",0,1,u,o.easing.cubic.out,f):(f(1),U=setTimeout(l,u+20))}else x=t.initialZoomLevel,qt(It,t.initialPosition),Ut(),Nt(1),s.showHideOpacity?e.style.opacity=1:Nt(1),U=setTimeout(l,u+20)},i?25:90),!0):(Lt("initialZoom"+(i?"Out":"In")),x=t.initialZoomLevel,qt(It,t.initialPosition),Ut(),e.style.opacity=i?0:1,Nt(1),l(),!1)},un={shout:Lt,listen:Pt,viewportSize:Ct,options:s,isMainScrollAnimating:function(){return ot},getZoomLevel:function(){return x},getCurrentIndex:function(){return m},isDragging:function(){return G},isZooming:function(){return Q},applyZoomPan:function(e,t,n){It.x=t,It.y=n,x=e,Ut()},init:function(){if(!u&&!c){var n;if(a.framework=o,a.template=e,a.bg=e.children[0],P=e.className,u=!0,_=o.detectFeatures(),R=_.raf,F=_.caf,A=_.transform,z=_.oldIE,a.scrollWrap=e.children[1],a.container=a.scrollWrap.children[0],p=a.container.style,A){var i=_.perspective&&!E;w="translate"+(i?"3d(":"("),b=_.perspective?", 0px)":")"}else A="left",o.addClass(e,"pswp--ie"),Yt=function(e,t){t.left=e+"px"},Ht=function(e){var t=e.container.style,n=e.fitRatio*e.w,i=e.fitRatio*e.h;t.width=n+"px",t.height=i+"px",t.left=e.initialPosition.x+"px",t.top=e.initialPosition.y+"px"},Ut=function(){if(it){var e=it,t=a.currItem,n=t.fitRatio*t.w,i=t.fitRatio*t.h;e.width=n+"px",e.height=i+"px",e.left=It.x+"px",e.top=It.y+"px"}};var r=function(e,t,n,i,o){M=e+t,Z=e+n,k=e+i,S=o?e+o:""};for(a.itemHolders=C=[{el:a.container.children[0],wrap:0,index:-1},{el:a.container.children[1],wrap:0,index:-1},{el:a.container.children[2],wrap:0,index:-1}],C[0].el.style.display=C[2].el.style.display="none",O=_.pointerEvent,O&&_.touch&&(_.touch=!1),O?navigator.pointerEnabled?r("pointer","down","move","up","cancel"):r("MSPointer","Down","Move","Up","Cancel"):_.touch?(r("touch","start","move","end","cancel"),E=!0):r("mouse","down","move","up"),h=Z+" "+k+" "+S,y=M,O&&!E&&(E=navigator.maxTouchPoints>1||navigator.msMaxTouchPoints>1),a.likelyTouchDevice=E,(!_.animationName||!_.transform||_.isOldIOSPhone||_.isOldAndroid||_.isMobileOpera)&&(s.showAnimationDuration=s.hideAnimationDuration=0),n=0;At.length>n;n++)a["init"+At[n]]();if(t){var g=a.ui=new t(a,o);g.init()}E||(s.allowPanToNext=!1),v={resize:a.updateSize,scroll:function(){D=!0,s.closeOnScroll&&u&&(!a.likelyTouchDevice||s.mouseUsed)&&Math.abs(o.getScrollY()-L)>2&&(d=!0,a.close())},keyup:function(e){s.escKey&&27===e.keyCode&&a.close()},keydown:function(e){s.arrowKeys&&(37===e.keyCode?a.prev():39===e.keyCode&&a.next())}},v[M]=_n,v[Z]=Un,v[k]=Yn,S&&(v[S]=v[k]),_.touch&&(y+=" mousedown",h+="mousemove mouseup",v.mousedown=v[M],v.mousemove=v[Z],v.mouseup=v[k]),Lt("firstUpdate"),m=m||s.index||0,(isNaN(m)||0>m||m>=yt())&&(m=0),a.currItem=ht(m),(_.isOldIOSPhone||_.isOldAndroid)&&(St=!1),s.modal&&(e.setAttribute("aria-hidden","false"),St?e.style.position="fixed":(e.style.position="absolute",e.style.top=o.getScrollY()+"px")),void 0===N&&(Lt("initialLayout"),N=L=o.getScrollY());var T="pswp--open ";for(s.mainClass&&(T+=s.mainClass+" "),s.showHideOpacity&&(T+="pswp--animate_opacity "),T+=E?"pswp--touch":"pswp--notouch",T+=_.animationName?" pswp--css_animation":"",T+=_.svg?" pswp--svg":"",o.addClass(e,T),a.updateSize(),f=-1,kt=null,n=0;l>n;n++)Yt((n+f)*Zt.x,C[n].el.style);z||o.bind(a.scrollWrap,y,a),Pt("initialZoomInEnd",function(){a.setContent(C[0],m-1),a.setContent(C[2],m+1),C[0].el.style.display=C[2].el.style.display="block",s.focus&&e.focus(),Kt()}),a.setContent(C[1],m),a.updateCurrItem(),Lt("afterInit"),St||(I=setInterval(function(){nn||G||Q||x!==a.currItem.initialZoomLevel||a.updateSize()},1e3)),o.addClass(e,"pswp--visible")}},close:function(){u&&(u=!1,c=!0,Lt("close"),$t(),sn(a.currItem,null,!0,a.destroy))},destroy:function(){Lt("destroy"),U&&clearTimeout(U),s.modal&&(e.setAttribute("aria-hidden","true"),e.className=P),I&&clearInterval(I),o.unbind(a.scrollWrap,y,a),o.unbind(window,"scroll",a),Tn(),rn(),Ft=null},panTo:function(e,t,n){n||(e>nt.min.x?e=nt.min.x:nt.max.x>e&&(e=nt.max.x),t>nt.min.y?t=nt.min.y:nt.max.y>t&&(t=nt.max.y)),It.x=e,It.y=t,Ut()},handleEvent:function(e){e=e||window.event,v[e.type]&&v[e.type](e)},goTo:function(e){e=Rt(e);var t=e-m;kt=t,m=e,a.currItem=ht(m),Tt-=t,Bt(Zt.x*Tt),rn(),ot=!1,a.updateCurrItem()},next:function(){a.goTo(m+1)},prev:function(){a.goTo(m-1)},updateCurrZoomItem:function(e){if(e&&Lt("beforeChange",0),C[1].el.children.length){var t=C[1].el.children[0];it=o.hasClass(t,"pswp__zoom-wrap")?t.style:null}else it=null;nt=a.currItem.bounds,g=x=a.currItem.initialZoomLevel,It.x=nt.center.x,It.y=nt.center.y,e&&Lt("afterChange")},invalidateCurrItems:function(){for(var e=0;l>e;e++)C[e].item&&(C[e].item.needsUpdate=!0)},updateCurrItem:function(e){if(0!==kt){var t,n=Math.abs(kt);if(!(e&&2>n)){a.currItem=ht(m),Lt("beforeChange",kt),n>=l&&(f+=kt+(kt>0?-l:l),n=l);for(var i=0;n>i;i++)kt>0?(t=C.shift(),C[l-1]=t,f++,Yt((f+2)*Zt.x,t.el.style),a.setContent(t,m-n+i+1+1)):(t=C.pop(),C.unshift(t),f--,Yt(f*Zt.x,t.el.style),a.setContent(t,m+n-i-1-1));if(it&&1===Math.abs(kt)){var o=ht(T);o.initialZoomLevel!==x&&(jn(o,Ct),Ht(o))}kt=0,a.updateCurrZoomItem(),T=m,Lt("afterChange")}}},updateSize:function(t){if(!St){var n=o.getScrollY();if(N!==n&&(e.style.top=n+"px",N=n),!t&&Ot.x===window.innerWidth&&Ot.y===window.innerHeight)return;Ot.x=window.innerWidth,Ot.y=window.innerHeight,e.style.height=Ot.y+"px"}if(Ct.x=a.scrollWrap.clientWidth,Ct.y=a.scrollWrap.clientHeight,rt={x:0,y:N},Zt.x=Ct.x+Math.round(Ct.x*s.spacing),Zt.y=Ct.y,Bt(Zt.x*Tt),Lt("beforeResize"),void 0!==f)for(var i,r,u=0;l>u;u++)i=C[u],Yt((u+f)*Zt.x,i.el.style),r=ht(i.index),r.needsUpdate&&(a.cleanSlide(r),a.setContent(i,i.index),1===u&&a.updateCurrZoomItem(!0),r.needsUpdate=!1),r&&r.container&&(jn(r,Ct),Ht(r));g=x=a.currItem.initialZoomLevel,nt=a.currItem.bounds,nt&&(It.x=nt.center.x,It.y=nt.center.y,Ut()),Lt("resize")},zoomTo:function(e,t,n,i,a){t&&(g=x,In.x=Math.abs(t.x)-It.x,In.y=Math.abs(t.y)-It.y,qt(bt,It));var r=Qt(e,!1),l={};en("x",r,l,e),en("y",r,l,e);var s=x,u={x:It.x,y:It.y},c=function(t){1===t?(x=e,It.x=l.x,It.y=l.y):(x=(e-s)*t+s,It.x=(l.x-u.x)*t+u.x,It.y=(l.y-u.y)*t+u.y),a&&a(t),Ut()};n?ln("customZoomTo",0,1,n,i||o.easing.sine.inOut,c):c(1)}},cn=30,dn=10,mn={},pn={},fn={},hn={},yn={},vn=[],xn={},gn=[],wn={},bn=xt(),In=xt(),Dn=xt(),Cn=function(e,t){return wn.x=Math.abs(e.x-t.x),wn.y=Math.abs(e.y-t.y),Math.sqrt(wn.x*wn.x+wn.y*wn.y)},Tn=function(){$&&(F($),$=null)},Mn=function(){G&&($=R(Mn),Hn())},Zn=function(){return!("fit"===s.scaleMode&&x===a.currItem.initialZoomLevel)},kn={},Sn=function(e,t){return kn.prevent="A"!==e.target.tagName,Lt("preventDragEvent",e,t,kn),kn.prevent},An=function(e,t){return t.x=e.pageX,t.y=e.pageY,t.id=e.identifier,t},On=function(e,t,n){n.x=.5*(e.x+t.x),n.y=.5*(e.y+t.y)},En=function(e,t,n){if(e-Y>50){var i=gn.length>2?gn.shift():{};i.x=t,i.y=n,gn.push(i),Y=e}},Rn=function(){var e=It.y-a.currItem.initialPosition.y;return 1-Math.abs(e/(Ct.y/2))},Fn={},Pn={},Ln=[],zn=function(e){for(;Ln.length>0;)Ln.pop();return O?(dt=0,vn.forEach(function(e){0===dt?Ln[0]=e:1===dt&&(Ln[1]=e),dt++})):e.type.indexOf("touch")>-1?e.touches&&e.touches.length>0&&(Ln[0]=An(e.touches[0],Fn),e.touches.length>1&&(Ln[1]=An(e.touches[1],Pn))):(Fn.x=e.pageX,Fn.y=e.pageY,Fn.id="",Ln[0]=Fn),Ln},Nn=function(e,t){var n,i,o=0,r=It[e]+t[e],l=t[e]>0,u=bn.x+t.x,c=bn.x-xn.x;n=r>nt.min[e]||nt.max[e]>r?s.panEndFriction:1,r=It[e]+t[e]*n;var d,m;return!s.allowPanToNext&&x!==a.currItem.initialZoomLevel||(it?"h"!==at||"x"!==e||q||(l?(r>nt.min[e]&&(n=s.panEndFriction,o=nt.min[e]-r,i=nt.min[e]-bt[e]),(0>=i||0>c)&&yt()>1?(m=u,0>c&&u>xn.x&&(m=xn.x)):nt.min.x!==nt.max.x&&(d=r)):(nt.max[e]>r&&(n=s.panEndFriction,o=r-nt.max[e],i=bt[e]-nt.max[e]),(0>=i||c>0)&&yt()>1?(m=u,c>0&&xn.x>u&&(m=xn.x)):nt.min.x!==nt.max.x&&(d=r))):m=u,"x"!==e)?(ot||j||x>a.currItem.fitRatio&&(It[e]+=t[e]*n),void 0):(void 0!==m&&(Bt(m,!0),j=m===xn.x?!1:!0),nt.min.x!==nt.max.x&&(void 0!==d?It.x=d:j||(It.x+=t.x*n)),void 0!==m)},_n=function(e){if(ft)return e.preventDefault(),void 0;if(Sn(e,!0)&&e.preventDefault(),Lt("pointerDown"),O){var t=o.arraySearch(vn,e.pointerId,"id");0>t&&(t=vn.length),vn[t]={x:e.pageX,y:e.pageY,id:e.pointerId}}var n=zn(e),i=n.length;J=null,rn(),G&&1!==i||(G=lt=!0,o.bind(window,h,a),W=ct=st=V=j=K=X=q=!1,at=null,Lt("firstTouchStart",n),qt(bt,It),wt.x=wt.y=0,qt(hn,n[0]),qt(yn,hn),xn.x=Zt.x*Tt,gn=[{x:hn.x,y:hn.y}],Y=H=zt(),Qt(x,!0),Tn(),Mn()),!Q&&i>1&&!ot&&!j&&(g=x,q=!1,Q=X=!0,wt.y=wt.x=0,qt(bt,It),qt(mn,n[0]),qt(pn,n[1]),On(mn,pn,Dn),In.x=Math.abs(Dn.x)-It.x,In.y=Math.abs(Dn.y)-It.y,et=tt=Cn(mn,pn))},Un=function(e){if(e.preventDefault(),O){var t=o.arraySearch(vn,e.pointerId,"id");if(t>-1){var n=vn[t];n.x=e.pageX,n.y=e.pageY}}if(G){var i=zn(e);if(at||K||Q)J=i;else{var a=Math.abs(i[0].x-hn.x)-Math.abs(i[0].y-hn.y);Math.abs(a)>=dn&&(at=a>0?"h":"v",J=i)}}},Hn=function(){if(J){var e=J.length;if(0!==e)if(qt(mn,J[0]),fn.x=mn.x-hn.x,fn.y=mn.y-hn.y,Q&&e>1){if(hn.x=mn.x,hn.y=mn.y,!fn.x&&!fn.y&&Gt(J[1],pn))return;qt(pn,J[1]),q||(q=!0,Lt("zoomGestureStarted"));var t=Cn(mn,pn),n=Wt(t);n>a.currItem.initialZoomLevel+a.currItem.initialZoomLevel/15&&(ct=!0);var i=1;if(a.currItem.minZoom>n)if(s.pinchToClose&&!ct&&a.currItem.initialZoomLevel>=g){var o=a.currItem.minZoom-n,r=1-o/(a.currItem.minZoom/1.2);Nt(r),Lt("onPinchClose",r),st=!0}else i=(a.currItem.minZoom-n)/a.currItem.minZoom,i>1&&(i=1),n=a.currItem.minZoom-i*(a.currItem.minZoom/3);else n>a.currItem.maxZoom&&(i=(n-a.currItem.maxZoom)/(6*a.currItem.minZoom),i>1&&(i=1),n=a.currItem.maxZoom+i*a.currItem.minZoom);1!==i&&0>i&&(i=0),et=t,On(mn,pn,Dt),wt.x+=Dt.x-Dn.x,wt.y+=Dt.y-Dn.y,qt(Dn,Dt),It.x=Vt("x",n),It.y=Vt("y",n),W=n>x,x=n,Ut()}else{if(!at)return;if(lt&&(lt=!1,Math.abs(fn.x)>=dn&&(fn.x-=J[0].x-yn.x),Math.abs(fn.y)>=dn&&(fn.y-=J[0].y-yn.y)),hn.x=mn.x,hn.y=mn.y,0===fn.x&&0===fn.y)return;if("v"===at&&s.closeOnVerticalDrag&&!Zn()){wt.y+=fn.y,It.y+=fn.y;var l=Rn();return V=!0,Lt("onVerticalDrag",l),Nt(l),Ut(),void 0}En(zt(),mn.x,mn.y),K=!0,nt=a.currItem.bounds;var u=Nn("x",fn);u||Nn("y",fn),Ut()}}},Yn=function(e){Lt("pointerUp"),Sn(e,!1)&&e.preventDefault();var t;if(O){var n=o.arraySearch(vn,e.pointerId,"id");if(n>-1)if(t=vn.splice(n,1)[0],navigator.pointerEnabled)t.type=e.pointerType||"mouse";else{var i={4:"mouse",2:"touch",3:"pen"};t.type=i[e.pointerType],t.type||(t.type=e.pointerType||"mouse")}}var r,l=zn(e),s=l.length;if("mouseup"===e.type&&(s=0),2===s)return J=null,!0;1===s&&qt(yn,l[0]),0!==s||at||ot||(t||("mouseup"===e.type?t={x:e.pageX,y:e.pageY,type:"mouse"}:e.changedTouches&&e.changedTouches[0]&&(t={x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY,type:"touch"})),Lt("touchRelease",e,t));var u=-1;if(0===s&&(G=!1,o.unbind(window,h,a),Tn(),Q?u=0:-1!==gt&&(u=zt()-gt)),gt=1===s?zt():-1,r=-1!==u&&150>u?"zoom":"swipe",Q&&2>s&&(Q=!1,1===s&&(r="zoomPointerUp"),Lt("zoomGestureEnded")),J=null,K||q||ot||V)if(rn(),B||(B=Bn()),B.calculateSwipeSpeed("x"),V){var c=Rn();if(.6>c)a.close();else{var d=It.y,m=ut;ln("verticalDrag",0,1,300,o.easing.cubic.out,function(e){It.y=(a.currItem.initialPosition.y-d)*e+d,Nt((1-m)*e+m),Ut()}),Lt("onVerticalDrag",1)}}else{if((j||ot)&&0===s){var p=Vn(r,B);if(p)return;r="zoomPointerUp"}if(!ot)return"swipe"!==r?(Gn(),void 0):(!j&&x>a.currItem.fitRatio&&Wn(B),void 0)}},Bn=function(){var e,t,n={lastFlickOffset:{},lastFlickDist:{},lastFlickSpeed:{},slowDownRatio:{},slowDownRatioReverse:{},speedDecelerationRatio:{},speedDecelerationRatioAbs:{},distanceOffset:{},backAnimDestination:{},backAnimStarted:{},calculateSwipeSpeed:function(i){gn.length>1?(e=zt()-Y+50,t=gn[gn.length-2][i]):(e=zt()-H,t=yn[i]),n.lastFlickOffset[i]=hn[i]-t,n.lastFlickDist[i]=Math.abs(n.lastFlickOffset[i]),n.lastFlickSpeed[i]=n.lastFlickDist[i]>20?n.lastFlickOffset[i]/e:0,.1>Math.abs(n.lastFlickSpeed[i])&&(n.lastFlickSpeed[i]=0),n.slowDownRatio[i]=.95,n.slowDownRatioReverse[i]=1-n.slowDownRatio[i],n.speedDecelerationRatio[i]=1},calculateOverBoundsAnimOffset:function(e,t){n.backAnimStarted[e]||(It[e]>nt.min[e]?n.backAnimDestination[e]=nt.min[e]:It[e]<nt.max[e]&&(n.backAnimDestination[e]=nt.max[e]),void 0!==n.backAnimDestination[e]&&(n.slowDownRatio[e]=.7,n.slowDownRatioReverse[e]=1-n.slowDownRatio[e],.05>n.speedDecelerationRatioAbs[e]&&(n.lastFlickSpeed[e]=0,n.backAnimStarted[e]=!0,ln("bounceZoomPan"+e,It[e],n.backAnimDestination[e],t||300,o.easing.sine.out,function(t){It[e]=t,Ut()}))))},calculateAnimOffset:function(e){n.backAnimStarted[e]||(n.speedDecelerationRatio[e]=n.speedDecelerationRatio[e]*(n.slowDownRatio[e]+n.slowDownRatioReverse[e]-n.slowDownRatioReverse[e]*n.timeDiff/10),n.speedDecelerationRatioAbs[e]=Math.abs(n.lastFlickSpeed[e]*n.speedDecelerationRatio[e]),n.distanceOffset[e]=n.lastFlickSpeed[e]*n.speedDecelerationRatio[e]*n.timeDiff,It[e]+=n.distanceOffset[e])},panAnimLoop:function(){return tn.zoomPan&&(tn.zoomPan.raf=R(n.panAnimLoop),n.now=zt(),n.timeDiff=n.now-n.lastNow,n.lastNow=n.now,n.calculateAnimOffset("x"),n.calculateAnimOffset("y"),Ut(),n.calculateOverBoundsAnimOffset("x"),n.calculateOverBoundsAnimOffset("y"),.05>n.speedDecelerationRatioAbs.x&&.05>n.speedDecelerationRatioAbs.y)?(on("zoomPan"),void 0):void 0}};return n},Wn=function(e){return e.calculateSwipeSpeed("y"),nt=a.currItem.bounds,e.backAnimDestination={},e.backAnimStarted={},.05>=Math.abs(e.lastFlickSpeed.x)&&.05>=Math.abs(e.lastFlickSpeed.y)?(e.speedDecelerationRatioAbs.x=e.speedDecelerationRatioAbs.y=0,e.calculateOverBoundsAnimOffset("x"),e.calculateOverBoundsAnimOffset("y"),!0):(an("zoomPan"),e.lastNow=zt(),e.panAnimLoop(),void 0)},Vn=function(e,t){var n;ot||(Mt=m);var i;if("swipe"===e){var r=hn.x-yn.x;r>cn&&(10>t.lastFlickDist.x||t.lastFlickOffset.x>20)?i=-1:-cn>r&&(10>t.lastFlickDist.x||-20>t.lastFlickOffset.x)&&(i=1)}var l;i&&(m+=i,0>m?(m=s.loop?yt()-1:0,l=!0):m>=yt()&&(m=s.loop?0:yt()-1,l=!0),(!l||s.loop)&&(kt+=i,Tt-=i,n=!0));var u,c=Zt.x*Tt,d=Math.abs(c-bn.x);return n||c>bn.x==t.lastFlickSpeed.x>0?(u=Math.abs(t.lastFlickSpeed.x)>0?d/Math.abs(t.lastFlickSpeed.x):333,u=Math.min(u,400),u=Math.max(u,250)):u=333,Mt===m&&(n=!1),ot=!0,ln("mainScroll",bn.x,c,u,o.easing.cubic.out,Bt,function(){rn(),ot=!1,Mt=-1,(n||Mt!==m)&&a.updateCurrItem(),Lt("mainScrollAnimComplete")}),n&&a.updateCurrItem(!0),n},Gn=function(){var e=x;a.currItem.minZoom>x?e=a.currItem.minZoom:x>a.currItem.maxZoom&&(e=a.currItem.maxZoom);var t,n=1,i=ut;return st&&!W&&!ct&&a.currItem.minZoom>x?(d=!0,a.close(),!0):(st&&(t=function(e){Nt((n-i)*e+i)}),a.zoomTo(e,0,300,o.easing.cubic.out,t),!0)},Xn={},qn={},Kn=[],$n={index:0,errorMsg:'<div class="pswp__error-msg"><a href="%url%" target="_blank">The image</a> could not be loaded.</div>',forceProgressiveLoading:!1,preload:[1,1],getNumItemsFn:function(){return mt.length}},jn=function(e,t,n){if(e.src){var i=!n;if(i&&(e.vGap||(e.vGap={top:0,bottom:0}),Lt("parseVerticalMargin",e)),Xn.x=t.x,Xn.y=t.y-e.vGap.top-e.vGap.bottom,i){var o=Xn.x/e.w,a=Xn.y/e.h;e.fitRatio=a>o?o:a,e.fillRatio=o>a?o:a;var r=s.scaleMode;"orig"===r?n=1:"fit"===r?n=e.fitRatio:"fill"===r&&(n=e.fillRatio),n>1&&(n=1),e.initialZoomLevel=n,e.maxZoom=2,e.doubleTapZoom=2*n>1?2*n:1,e.minZoom=n,e.bounds||(e.bounds={center:{},max:{},min:{}})}if(!n)return;qn.x=e.w*n,qn.y=e.h*n;var l=e.bounds;return l.center.x=Math.round((Xn.x-qn.x)/2),l.center.y=Math.round((Xn.y-qn.y)/2)+e.vGap.top,l.max.x=qn.x>Xn.x?Math.round(Xn.x-qn.x):l.center.x,l.max.y=qn.y>Xn.y?Math.round(Xn.y-qn.y)+e.vGap.top:l.center.y,l.min.x=qn.x>Xn.x?0:l.center.x,l.min.y=qn.y>Xn.y?e.vGap.top:l.center.y,i&&n===e.initialZoomLevel&&(e.initialPosition=l.center),l}return!1},Jn=function(e,t,n,i,o,r){var l;!o&&(E||s.alwaysFadeIn)&&(e===m||a.isMainScrollAnimating()||a.isDragging()&&!a.isZooming())&&(l=!0),i&&(l&&(i.style.opacity=0),t.imageAppended=!0,n.appendChild(i),l&&setTimeout(function(){i.style.opacity=1,r&&setTimeout(function(){t&&t.loaded&&t.placeholder&&(t.placeholder.style.display="none",t.placeholder=null)},500)},50))},Qn=function(e){e.loading=!0,e.loaded=!1;var t=e.img=o.createEl("pswp__img","img"),n=function(){e.loading=!1,e.loaded=!0,e.loadComplete?e.loadComplete(e):e.img=null,t.onload=t.onerror=null,t=null};return t.onload=n,t.onerror=function(){e.loadError=!0,n()},t.src=e.src,t},ei=function(e,t){return e.loadError?(t.el.innerHTML=s.errorMsg.replace("%url%",e.src),!0):void 0},ti=function(){if(Kn.length){for(var e,t=0;Kn.length>t;t++)e=Kn[t],e.holder.index===e.index&&Jn(e.index,e.item,e.baseDiv,e.img);Kn=[]}};Et("Controller",{publicMethods:{lazyLoadItem:function(e){e=Rt(e);var t=ht(e);!t||t.loaded||t.loading||(Lt("gettingData",e,t),Qn(t))},initController:function(){o.extend(s,$n,!0),a.items=mt=n,ht=a.getItemAt,yt=s.getNumItemsFn,vt=s.loop,3>yt()&&(s.loop=!1),Pt("beforeChange",function(e){var t,n=s.preload,i=null===e?!0:e>0,o=Math.min(n[0],yt()),r=Math.min(n[1],yt());for(t=1;(i?r:o)>=t;t++)a.lazyLoadItem(m+t);for(t=1;(i?o:r)>=t;t++)a.lazyLoadItem(m-t)}),Pt("initialLayout",function(){a.currItem.initialLayout=s.getThumbBoundsFn&&s.getThumbBoundsFn(m)}),Pt("mainScrollAnimComplete",ti),Pt("initialZoomInEnd",ti),Pt("destroy",function(){for(var e,t=0;mt.length>t;t++)e=mt[t],e.container&&(e.container=null),e.placeholder&&(e.placeholder=null),e.img&&(e.img=null),e.preloader&&(e.preloader=null),e.loadError&&(e.loaded=e.loadError=!1);Kn=null})},getItemAt:function(e){return e>=0?void 0!==mt[e]?mt[e]:!1:!1},allowProgressiveImg:function(){return s.forceProgressiveLoading||!E||s.mouseUsed||screen.width>1200},setContent:function(e,t){s.loop&&(t=Rt(t));var n=a.getItemAt(e.index);n&&(n.container=null);var i,r=a.getItemAt(t);if(r){if(Lt("gettingData",t,r),e.index=t,e.item=r,ei(r,e))return r.initialPosition.x=r.initialPosition.y=0,r.initialZoomLevel=r.maxZoom=r.minZoom=1,it=null,r.w=50,r.h=50,Ht(r),void 0;var l=r.container=o.createEl("pswp__zoom-wrap");if(r.loaded)i=o.createEl("pswp__img","img"),i.style.webkitBackfaceVisibility="hidden",i.style.opacity=1,i.src=r.src,Jn(t,r,l,i,!0);else{if(r.loadComplete=function(n){if(u){if(n.img.style.webkitBackfaceVisibility="hidden",e.index===t){if(ei(n,e))return n.img=null,void 0;n.imageAppended?!ft&&n.placeholder&&(n.placeholder.style.display="none",n.placeholder=null):ot||ft?Kn.push({item:n,baseDiv:l,img:n.img,index:t,holder:e}):Jn(t,n,l,n.img,ot||ft)}n.loadComplete=null,n.img=null,Lt("imageLoadComplete",t,n)}},o.features.transform){var c=o.createEl("pswp__img pswp__img--placeholder"+(r.msrc?"":" pswp__img--placeholder--blank"),r.msrc?"img":"");r.msrc&&(c.src=r.msrc),c.style.width=r.w+"px",c.style.height=r.h+"px",l.appendChild(c),r.placeholder=c}r.loading||Qn(r),a.allowProgressiveImg()&&(pt?Jn(t,r,l,r.img,!0,!0):Kn.push({item:r,baseDiv:l,img:r.img,index:t,holder:e}))}jn(r,Ct),pt||t!==m?Ht(r):(it=l.style,sn(r,i||r.img)),e.el.innerHTML="",e.el.appendChild(l)}else e.el.innerHTML=""},cleanSlide:function(e){e.img&&(e.img.onload=e.img.onerror=null),e.loaded=e.loading=e.img=e.imageAppended=!1}}});var ni,ii={},oi=function(e,t,n){var i=document.createEvent("CustomEvent");i.initCustomEvent("pswpTap",!0,!0,{origEvent:e,target:e.target,releasePoint:t,pointerType:n||"touch"}),e.target.dispatchEvent(i)};Et("Tap",{publicMethods:{initTap:function(){Pt("firstTouchStart",a.onTapStart),Pt("touchRelease",a.onTapRelease),Pt("destroy",function(){ii={},ni=null})},onTapStart:function(e){e.length>1&&(clearTimeout(ni),ni=null)},onTapRelease:function(e,t){if(t&&!K&&!X&&!nn){var n=t;if(ni&&(clearTimeout(ni),ni=null,Xt(n,ii)))return Lt("doubleTap",n),void 0;var i=e.target.tagName.toLowerCase();if("mouse"===t.type)return oi(e,t,"mouse"),void 0;if("button"===i||o.hasClass(e.target,"pswp__single-tap"))return oi(e,t),void 0;qt(ii,n),ni=setTimeout(function(){oi(e,t),ni=null},300)}}}});var ai;Et("DesktopZoom",{publicMethods:{handleMouseWheel:function(e){if(a.currItem.fitRatio>=x)return!0;if(e.preventDefault(),e.stopPropagation(),ai.x=0,"deltaX"in e)ai.x=e.deltaX,ai.y=e.deltaY;else if("wheelDelta"in e)e.wheelDeltaX&&(ai.x=-.16*e.wheelDeltaX),ai.y=e.wheelDeltaY?-.16*e.wheelDeltaY:-.16*e.wheelDelta;else{if(!("detail"in e))return;ai.y=e.detail}Qt(x,!0),a.panTo(It.x-ai.x,It.y-ai.y)},toggleDesktopZoom:function(t){t=t||{x:Ct.x/2,y:Ct.y/2+L};var n=1===x;a.mouseZoomedIn=!n,a.zoomTo(n?a.currItem.initialZoomLevel:1,t,333),o[(n?"remove":"add")+"Class"](e,"pswp--zoomed-in")},setupDesktopZoom:function(t){ai={};var n="wheel mousewheel DOMMouseScroll";Pt("bindEvents",function(){o.bind(e,n,a.handleMouseWheel)}),Pt("unbindEvents",function(){ai&&o.unbind(e,n,a.handleMouseWheel)}),a.mouseZoomedIn=!1;var i,r=function(){a.mouseZoomedIn&&(o.removeClass(e,"pswp--zoomed-in"),a.mouseZoomedIn=!1),1>x?o.addClass(e,"pswp--zoom-allowed"):o.removeClass(e,"pswp--zoom-allowed"),l()},l=function(){i&&(o.removeClass(e,"pswp--dragging"),i=!1)};Pt("resize",r),Pt("afterChange",r),Pt("pointerDown",function(){a.mouseZoomedIn&&(i=!0,o.addClass(e,"pswp--dragging"))}),Pt("pointerUp",l),t||r()},initDesktopZoom:function(){z||(E?Pt("mouseUsed",function(){a.setupDesktopZoom()}):a.setupDesktopZoom(!0))}}});var ri,li,si,ui,ci,di,mi,pi,fi,hi,yi,vi={history:!0,galleryUID:1},xi=function(){return yi.hash.substring(1)},gi=function(){ri&&clearTimeout(ri),si&&clearTimeout(si)},wi=function(){var e=xi(),t={};if(5>e.length)return t;for(var n=e.split("&"),i=0;n.length>i;i++)if(n[i]){var o=n[i].split("=");2>o.length||(t[o[0]]=o[1])}return t.pid=parseInt(t.pid,10)-1,0>t.pid&&(t.pid=0),t},bi=function(){if(si&&clearTimeout(si),nn||G)return si=setTimeout(bi,500),void 0;ui?clearTimeout(li):ui=!0;var e=mi+"&"+"gid="+s.galleryUID+"&"+"pid="+(m+1);if(pi){var t=yi.href.split("#")[0]+"#"+e;yi.replace(t)}else-1===yi.hash.indexOf(e)&&(hi=!0),yi.hash=e;pi=!0,li=setTimeout(function(){ui=!1},60)};Et("History",{publicMethods:{initHistory:function(){if(o.extend(s,vi,!0),s.history){yi=window.location,hi=!1,fi=!1,pi=!1,mi=xi(),mi.indexOf("gid=")>-1&&(mi=mi.split("&gid=")[0],mi=mi.split("?gid=")[0]),Pt("afterChange",a.updateURL),Pt("unbindEvents",function(){o.unbind(window,"hashchange",a.onHashChange)});var e=function(){di=!0,fi||(hi?history.back():mi?yi.hash=mi:"pushState"in history?history.pushState("",document.title,yi.pathname+yi.search):yi.hash=""),gi()};Pt("unbindEvents",function(){d&&e()}),Pt("destroy",function(){di||e()}),Pt("firstUpdate",function(){m=wi().pid});var t=mi.indexOf("pid=");t>-1&&(mi=mi.substring(0,t),"&"===mi.slice(-1)&&(mi=mi.slice(0,-1))),setTimeout(function(){u&&o.bind(window,"hashchange",a.onHashChange)},40)}},onHashChange:function(){return xi()===mi?(fi=!0,a.close(),void 0):(ui||(ci=!0,a.goTo(wi().pid),ci=!1),void 0)},updateURL:function(){gi(),ci||(pi?ri=setTimeout(bi,800):bi())}}}),o.extend(a,un)};return e});