smartphoto 2.1.17 → 2.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * SmartPhoto v2.1.17
2
+ * SmartPhoto v2.1.18
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
@@ -64,6 +64,10 @@
64
64
  var getWindowHeight = () => {
65
65
  const visualViewport = window.visualViewport;
66
66
  if (visualViewport) {
67
+ const layoutWidth = document.documentElement.clientWidth;
68
+ if (visualViewport.width > 0 && layoutWidth > 0) {
69
+ return visualViewport.height * (layoutWidth / visualViewport.width);
70
+ }
67
71
  return visualViewport.height * visualViewport.scale;
68
72
  }
69
73
  return document.documentElement.clientHeight;
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * SmartPhoto v2.1.17
2
+ * SmartPhoto v2.1.18
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
6
- "use strict";(()=>{var ae=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},Me=()=>typeof window.webkitConvertPointFromNodeToPage=="function";function Ve(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let n=e[o];if(n){for(let s in n)if(Object.hasOwn(n,s)){let r=n[s];r&&typeof r=="object"?t[s]=Ve((i=t[s])!=null?i:{},r):t[s]=r}}}return t}var ze=Ve,Oe=(t,e,i)=>{let o;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,i)),t.dispatchEvent(o)},Ne=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),n=o[0],s=o.length>1?o.slice(1).join("="):n;e[n]=decodeURIComponent(s)}return e},le=()=>document.documentElement.clientWidth,he=()=>{let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight},Be=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var He=t=>{let e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/);return e?[Number(e[1]),Number(e[2]),Number(e[3])]:null},tt=.179,it=([t,e,i])=>{let[o,n,s]=[t,e,i].map(r=>{let m=r/255;return m<=.03928?m/12.92:((m+.055)/1.055)**2.4});return .2126*o+.7152*n+.0722*s},De=t=>{let e=t.trim(),i=He(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=He(getComputedStyle(o).color),document.body.removeChild(o)}return i&&it(i)>tt?"#000":"#fff"};var ot={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,useViewTransitionApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,pinchToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:300};function Re(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Re(i)}),Object.freeze(t)}function Xe(t){return{options:Re(ze({},ot,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function ee(t){return t.getAttribute("data-group")||"nogroup"}function Ee(t){return t.group||"nogroup"}function Pe(t,e,i,o){let n=ee(t),s=t.getAttribute("href"),r=t.querySelector("img"),m=s;r&&(r.getAttribute(e.lazyAttribute)?m=r.getAttribute(e.lazyAttribute):r.currentSrc?m=r.currentSrc:m=r.src);let p="";r!=null&&r.getAttribute("alt")?p=r.getAttribute("alt"):t.getAttribute("data-caption")?p=t.getAttribute("data-caption"):p=s!=null?s:"";let c=t.getAttribute("data-id");return{src:s,thumb:m,caption:t.getAttribute("data-caption"),alt:p,groupId:n,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:c||i,loaded:!1,processed:!1,element:t}}function Ye(t,e,i){var c,f,x,b,M;let o=Ee(t),n=t.src,s=(c=t.thumb)!=null?c:n,r=(f=t.caption)!=null?f:null,m=(b=(x=t.alt)!=null?x:r)!=null?b:n,p=typeof t.width=="number"&&typeof t.height=="number";return{src:n,thumb:s,caption:r,alt:m,groupId:o,translateX:i*e,translateY:0,index:e,width:p?t.width:50,height:p?t.height:50,scale:1,x:0,y:0,id:(M=t.id)!=null?M:e,loaded:p,processed:!1,element:null}}function be(t,e){t.groups.has(e.groupId)||t.groups.set(e.groupId,[]),t.groups.get(e.groupId).push(e),t.viewer.currentGroup=e.groupId}function I(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function L(t){var i;let e=I(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function Se(t){let e=I(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,n=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),n!==-1&&(t.viewer.prev=n,t.viewer.showPrevArrow=!0)}function xe(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function ue(t,e){let i=10**e;return Math.round(t*i)/i}function _(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Fe(t,e,i,o){let n=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,r,m,p,c;return i>n?(p=(i-n)/2,r=-1*p):(p=(n-i)/2,r=-1*p),o>s?(c=(o-s)/2,m=-1*c):(c=(s-o)/2,m=-1*c),{minX:ue(r,6)/t.scale,minY:ue(m,6)/t.scale,maxX:ue(p,6)/t.scale,maxY:ue(c,6)/t.scale}}var nt=24;function Ge(t,e,i,o,n){let s=i-(o+n)-nt*2;t.forEach(r=>{r.loaded&&(r.processed=!0,r.scale=s/r.height,r.height<s&&(r.scale=1),r.x=(r.scale-1)/2*r.width+(e-r.width*r.scale)/2,r.y=(r.scale-1)/2*r.height+(i-r.height*r.scale)/2,r.width*r.scale>e&&(r.scale=e/r.width,r.x=(r.scale-1)/2*r.width))})}function We(t){let e=L(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function $e(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(n=>{e.group===n.groupId&&e.photo===n.id&&(i=n)})}),i}function te(t,e){let i=10**e;return Math.round(t*i)/i}function K(t){return{x:t.clientX,y:t.clientY}}function ke(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var rt=10;function st(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ie(){return{width:le(),height:he()}}function Ue({state:t,callbacks:e},{signal:i}){let o=new Map,n=Date.now(),s=!1,r=!1,m=null,p=null,c=null,f=0,x=null,b=!1,M=null,C=null,N=0,W=0,z=!1,B=0,D=1,V=null,u=0,R=0;function j(){return ae()}function q(a){let{width:h,height:w}=Ie();return Fe(a,t.viewer,h,w)}function oe(a){let{width:h,height:w}=Ie();return _(a,h,w,j())}function $(a){return t.options.resizeStyle==="fill"&&j()?oe(a):1}let ne=4;function de(a){return Math.max(ne,oe(a))}let me=.75;function re(a,h){let w=L(t),g=q(w);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=g.minX:a===-1&&(t.viewer.photoPosX=g.maxX),h===1?t.viewer.photoPosY=g.minY:h===-1&&(t.viewer.photoPosY=g.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let pe=setInterval(()=>{if(z||s||b||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=u,t.viewer.photoPosY+=R;let a=L(t);if(!a)return;let h=q(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,u*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,u*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,R*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,R*=-.2);let w=st(u,R),g=w.force-t.options.registance;g<.5||(u=Math.cos(w.theta)*g,R=Math.sin(w.theta)*g,e.onPhotoDragMove())},t.options.forceInterval);function Q(a,h){(a>5||a<-5)&&(u+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(R+=h*.05)}function fe(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||z||s||b||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?Q(a.gamma,a.beta):h===90?Q(a.beta,a.gamma):h===-90?Q(-a.beta,-a.gamma):h===180&&Q(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",fe,{signal:i});function se(){let a=Array.from(o.values());B=ke(a[0],a[1]),D=t.viewer.scaleSize}function ve(){z=!0,s=!1,b=!1,se(),u=0,R=0,t.viewer.scale=!0,t.viewer.hideUi=!0,e.onGestureStart()}function d(a){let h=K(a);s=!0,r=!0,m=h,p=h,f=Date.now(),x=a.target}function l(a){b=!0;let h=K(a);C=h,M=h}function v(a){var h,w;try{(w=(h=a.currentTarget).setPointerCapture)==null||w.call(h,a.pointerId)}catch(g){}if(o.set(a.pointerId,K(a)),o.size>1){ve();return}if(t.viewer.scale){l(a);return}d(a)}function y(){V===null&&(V=requestAnimationFrame(()=>{V=null,e.onGestureMove()}))}function P(){V!==null&&(cancelAnimationFrame(V),V=null,e.onGestureMove())}function E(){let a=Array.from(o.values()),h=a[0],w=a[1],g=ke(h,w);if(B===0){B=g,D=t.viewer.scaleSize,y();return}let S=t.viewer.scaleSize;t.viewer.scaleSize=te(D*g/B,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2);let H=L(t);if(H&&t.viewer.scaleSize!==S){let{width:G,height:ge}=Ie(),Z=G/2,Y=t.options.headerHeight+(ge-t.options.headerHeight-t.options.footerHeight)/2,J=H.scale,U={x:(h.x+w.x)/2,y:(h.y+w.y)/2},Ae=t.viewer.scaleSize/S,Ze=U.x-(Z+t.viewer.photoPosX*J),et=U.y-(Y+t.viewer.photoPosY*J);t.viewer.photoPosX=te((U.x-Ze*Ae-Z)/J,6),t.viewer.photoPosY=te((U.y-et*Ae-Y)/J,6)}y()}function A(a){let h=K(a),w=h.x-p.x,g=h.y-m.y;r&&(e.onSwipeStart(),r=!1,c=Math.abs(w)>Math.abs(g)?"horizontal":"vertical"),c==="horizontal"?t.viewer.translateX+=w:t.viewer.translateY=g,p=h,e.onSwipeMove()}function k(a){let h=K(a),w=h.x-C.x,g=h.y-C.y,S=te(t.viewer.scaleSize*w,6),H=te(t.viewer.scaleSize*g,6);t.viewer.photoPosX+=S,N=S,t.viewer.photoPosY+=H,W=H,C=h,e.onPhotoDragMove()}function X(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,K(a)),z){E();return}if(b){k(a);return}A(a)}}function F(){z=!1,P();let a=L(t);if(!a)return;let h=$(a);if(t.viewer.scaleSize<=h){if(t.options.pinchToClose&&t.viewer.scaleSize<h*me){e.onPinchClose();return}t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scaleSize=h,t.viewer.scale=h>1,t.viewer.hideUi=h>1,e.onGestureEnd();return}t.viewer.scaleSize=Math.min(t.viewer.scaleSize,de(a));let w=q(a),g=0,S=0;t.viewer.photoPosX>w.maxX?g=-1:t.viewer.photoPosX<w.minX&&(g=1),t.viewer.photoPosY>w.maxY?S=-1:t.viewer.photoPosY<w.minY&&(S=1),(g!==0||S!==0)&&re(g,S),t.viewer.scale=!0,t.viewer.hideUi=!0,e.onGestureEnd()}function we(){var Z;s=!1;let a=m,h=p,w=Date.now(),g=n-w,S=h.x-a.x,H=h.y-a.y,G=S===0&&H===0;if(!j()&&G){e.onTap(x);return}if(Math.abs(g)<=500&&G){e.onTap(x);return}n=w;let ge=(Z=I(t))!=null?Z:[];if(c==="horizontal"){let Y="stay",J=Math.max(w-f,1),U=Math.abs(S)>=rt&&Math.abs(S)/J>=t.options.swipeVelocity;(S>=t.options.swipeOffset||U&&S>0)&&t.viewer.currentIndex!==0?Y="prev":(S<=-t.options.swipeOffset||U&&S<0)&&t.viewer.currentIndex!==ge.length-1&&(Y="next"),e.onSwipeEnd(Y)}else{let Y="stay";t.options.swipeBottomToClose&&H>=t.options.swipeOffset?Y="close-bottom":t.options.swipeTopToClose&&H<=-t.options.swipeOffset&&(Y="close-top"),e.onSwipeEnd(Y)}}function Qe(){b=!1;let a=C,h=M;if(a.x===h.x&&a.y===h.y){e.onPhotoDragEnd("zoom-out");return}let w=L(t);if(!w){e.onPhotoDragEnd(null);return}let g=q(w),S=t.options.swipeOffset*t.viewer.scaleSize,H=0,G=0;if(t.viewer.photoPosX>g.maxX?H=-1:t.viewer.photoPosX<g.minX&&(H=1),t.viewer.photoPosY>g.maxY?G=-1:t.viewer.photoPosY<g.minY&&(G=1),t.viewer.photoPosX-g.maxX>S&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(g.minX-t.viewer.photoPosX>S&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}H===0&&G===0?(u=N/5,R=W/5):re(H,G),e.onPhotoDragEnd(null)}function Ce(a){if(o.delete(a.pointerId),z){o.size<2?(F(),o.clear()):se();return}if(b){Qe();return}s&&we()}function Je(...a){for(let h of a)h.addEventListener("pointerdown",v,{signal:i}),h.addEventListener("pointermove",X,{signal:i}),h.addEventListener("pointerup",Ce,{signal:i}),h.addEventListener("pointercancel",Ce,{signal:i})}function Ke(){clearInterval(pe),V!==null&&(cancelAnimationFrame(V),V=null)}return{attach:Je,detach:Ke}}function ce(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function Le(){let t=document.createElement("button");return t.type="button",t}function at(t){return t.replace(/"/g,'\\"')}function _e({id:t,options:e},i,{signal:o}){let{classNames:n,message:s}=e,r=document.createElement("div");r.setAttribute("data-id",t);let m=document.createElement("dialog");m.className=n.smartPhoto,m.setAttribute("aria-labelledby",`smartphoto-${t}-title`),m.style.display="none",m.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=n.smartPhotoBody;let c=document.createElement("div");c.className=n.smartPhotoInner;let f=document.createElement("div");f.className=n.smartPhotoHeader;let x=document.createElement("span");x.className=n.smartPhotoCount;let b=document.createElement("h1");b.id=`smartphoto-${t}-title`,b.className=n.smartPhotoCaption,b.setAttribute("tabindex","-1");let M=document.createElement("button");M.className=n.smartPhotoDismiss,M.appendChild(ce(s.closeDialog)),M.addEventListener("click",()=>i.onDismiss(),{signal:o}),f.append(x,b,M);let C=document.createElement("div");C.className=n.smartPhotoContent,C.addEventListener("click",d=>{d.target===C&&i.onBackdropClick()},{signal:o});let N=document.createElement("ul");N.className=n.smartPhotoList,N.setAttribute("role","region"),N.setAttribute("aria-roledescription","carousel"),N.setAttribute("aria-label",s.carouselLabel),N.setAttribute("aria-live","polite"),N.setAttribute("aria-atomic","false"),c.append(f,C,N);let W=null,z=null,B=null;if(e.arrows){W=document.createElement("ul"),W.className=n.smartPhotoArrows,z=document.createElement("li"),z.className=n.smartPhotoArrowLeft;let d=Le();d.appendChild(ce(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),z.appendChild(d),B=document.createElement("li"),B.className=n.smartPhotoArrowRight;let l=Le();l.appendChild(ce(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),B.appendChild(l),W.append(z,B),c.appendChild(W)}let D=null,V=null;e.nav&&(D=document.createElement("nav"),D.className=n.smartPhotoNav,D.setAttribute("aria-label","Choose slide to display"),V=document.createElement("ul"),D.appendChild(V),c.appendChild(D)),p.appendChild(c),m.appendChild(p),r.appendChild(m);let u={dialog:m,count:x,caption:b,dismiss:M,content:C,list:N,arrows:W,arrowLeft:z,arrowRight:B,nav:D,navList:V,slides:new Map,imgClone:null};function R(){let d=document.createElement("div");d.className=n.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=n.smartPhotoLoader,d.appendChild(l),d}function j(d){var y,P;let l=document.createElement("div");l.className=n.smartPhotoImgWrap;let v=document.createElement("img");return v.className=n.smartPhotoImg,v.src=(y=d.src)!=null?y:"",v.alt=(P=d.alt)!=null?P:"",v.addEventListener("dragstart",E=>E.preventDefault(),{signal:o}),l.appendChild(v),{imgWrap:l,img:v}}function q(d,l){var v;u.list.replaceChildren(),(v=u.navList)==null||v.replaceChildren(),u.slides=new Map,d.forEach(y=>{var A,k;let P=document.createElement("li");P.setAttribute("role","group"),P.setAttribute("aria-roledescription","slide"),P.setAttribute("aria-label",`${y.index+1} of ${d.length}`);let E={li:P,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(y.processed){let{imgWrap:X,img:F}=j(y);P.appendChild(X),E.imgWrap=X,E.img=F}else{let X=R();P.appendChild(X),E.loaderWrap=X}if(u.list.appendChild(P),u.slides.set(y,E),u.navList){let X=document.createElement("li"),F=Le();F.style.backgroundImage=`url("${at((A=y.thumb)!=null?A:"")}")`;let we=y.index;F.addEventListener("click",()=>i.onNavigate(we),{signal:o}),F.appendChild(ce(`go to ${(k=y.caption)!=null?k:""}`)),X.appendChild(F),u.navList.appendChild(X),E.navLink=F}}),ne(l)}function oe(d,l){var P;if(l.imgWrap||!d.processed)return l;let{imgWrap:v,img:y}=j(d);return(P=l.loaderWrap)==null||P.replaceWith(v),l.loaderWrap=null,l.imgWrap=v,l.img=y,l}function $(d){d&&document.activeElement&&d.contains(document.activeElement)&&u.caption.focus()}function ne(d,l){let{viewer:v}=d;u.count.textContent=`${v.currentIndex+1}/${v.total}`,u.slides.forEach((y,P)=>{var k;let E=oe(P,y),A=P.index===v.currentIndex;E.li.style.transition=l!=null&&l.immediate?"none":"",E.li.style.transform=`translate(${P.translateX}px,${P.translateY}px)`,E.li.classList.toggle("current",A),A?E.li.removeAttribute("aria-hidden"):E.li.setAttribute("aria-hidden","true"),A&&(u.caption.textContent=(k=P.caption)!=null?k:""),E.imgWrap&&E.img&&(E.imgWrap.style.transform=`translate(${P.x}px,${P.y}px) scale(${P.scale})`,E.img.style.width=`${P.width}px`,A||(E.img.style.transform="translate(0px,0px) scale(1)"),E.img.classList.toggle("active",v.appear),E.img.classList.toggle(n.smartPhotoImgOnMove,v.scale),E.img.classList.toggle(n.smartPhotoImgElasticMove,v.elastic)),E.navLink&&(E.navLink.classList.toggle("current",A),A?E.navLink.setAttribute("aria-current","true"):E.navLink.removeAttribute("aria-current"))}),u.arrowLeft&&(v.showPrevArrow?u.arrowLeft.removeAttribute("aria-hidden"):($(u.arrowLeft),u.arrowLeft.setAttribute("aria-hidden","true"))),u.arrowRight&&(v.showNextArrow?u.arrowRight.removeAttribute("aria-hidden"):($(u.arrowRight),u.arrowRight.setAttribute("aria-hidden","true"))),u.arrows&&(v.hideUi&&$(u.arrows),u.arrows.setAttribute("aria-hidden",v.hideUi?"true":"false")),u.nav&&(v.hideUi&&$(u.nav),u.nav.setAttribute("aria-hidden",v.hideUi?"true":"false"))}function de(d){for(let[l,v]of u.slides)if(l.index===d.viewer.currentIndex)return v;return null}function me(d){let{viewer:l}=d,v=de(d),y=v==null?void 0:v.img;y&&(y.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,y.classList.toggle(n.smartPhotoImgOnMove,l.scale),y.classList.toggle(n.smartPhotoImgElasticMove,l.elastic)),u.nav&&(l.hideUi&&$(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.arrows&&(l.hideUi&&$(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function re(d){let{viewer:l}=d;u.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,u.list.classList.toggle(n.smartPhotoListOnMove,l.onMove)}function pe(d){for(let[l,v]of u.slides){if(l.index!==d.viewer.currentIndex)continue;let{img:y,imgWrap:P}=v;if(!y||!P||!l.width||!l.scale||l.scale>=1)return;let E=y.getBoundingClientRect();y.style.width=`${l.width*l.scale}px`,P.style.transform=`translate(${l.x}px,${l.y}px) scale(1)`;let A=y.getBoundingClientRect();P.style.transform=`translate(${l.x+E.left-A.left}px,${l.y+E.top-A.top}px) scale(1)`;return}}function Q(){for(let[d,l]of u.slides){let{img:v,imgWrap:y}=l;v&&y&&(y.style.transform=`translate(${d.x}px,${d.y}px) scale(${d.scale})`,v.style.width=`${d.width}px`)}}function fe(d){let l=document.createElement("img");l.className=n.smartPhotoImgClone,l.src=d.img,l.style.width=`${d.width}px`,l.style.height=`${d.height}px`,l.style.transform=`translate(${d.left}px,${d.top}px) scale(1)`,p.appendChild(l),u.imgClone=l}function se(){var d;(d=u.imgClone)==null||d.remove(),u.imgClone=null}function ve(){r.remove()}return{root:r,refs:u,render:ne,syncSlides:q,updatePhotoTransform:me,applyViewTransitionLayout:pe,resetViewTransitionLayout:Q,updateListTransform:re,showAppearEffect:fe,removeAppearEffect:se,destroy:ve}}var T=le,O=he;function lt(t){return t.length>0&&t[0]instanceof Element}function ht(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function je(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var ie=class{constructor(e,i){this.id=ht();this.abortController=new AbortController;this.isSmartPhoneFlag=ae();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.isViewTransitionActive=!1;this.pendingViewTransitionResync=!1;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.rootSelector=null;this.itemsByElement=new Map;this.handleDocumentClick=e=>{if(!(e.target instanceof Element))return;let i=e;if(i.__smartphotoClaimed)return;let o=this.findRegisteredAncestor(e.target);if(!o&&this.rootSelector&&(o=e.target.closest(this.rootSelector)),!o)return;if(e.preventDefault(),i.__smartphotoClaimed=!0,!this.itemsByElement.has(o)&&this.rootSelector){let s=ee(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let n=this.itemsByElement.get(o);n&&this.openPhoto(n,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${O()}px`)};this.handleVisualViewportResize=()=>{if(this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!I(this.state))){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit(!0)}};this.handleResize=()=>{if(!(!this.state.viewer.isOpen||!I(this.state))){if(this.updateViewportHeight(),this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit(!0)}};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!this.state.viewer.isOpen||!I(this.state))return;if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit(!0);let e=T(),i=O(),o=500,n=s=>{this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(e!==T()||i!==O()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit(!0)):s<=o&&n(s+25))},25)};n(0)};this.rootSelector=typeof e=="string"?e:null,this.state=Xe(i!=null?i:{}),this.view=_e({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Ue({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),document.addEventListener("click",this.handleDocumentClick,{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&this.openPhoto(o,o.element),this.updateViewportHeight(),this.applyAutoIconContrast(),window.visualViewport?window.visualViewport.addEventListener("resize",this.handleVisualViewportResize,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,n=s=>i.call(o,s);o.addEventListener(e,n,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.itemsByElement.clear(),this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){var s,r;let i=Number.parseInt(String(e),10),o=Number.isNaN(i)?0:i,n=(r=(s=I(this.state))==null?void 0:s.length)!=null?r:0;o<0||o>=n||(this.state.viewer.currentIndex=o,this.slideList())}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=je();location.hash&&this.setHash(""),window.scroll(i.x,i.y),this.syncDialog(),(o=this.lastTriggerElement)!=null&&o.isConnected&&this.lastTriggerElement.focus(),this.lastTriggerElement=null,this.doHideEffect(e).then(()=>{this.view.render(this.state),this.isFiringPublicCloseEvent=!0,this.fireEvent("close"),this.isFiringPublicCloseEvent=!1})}zoomPhoto(){let e=L(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=_(e,T(),O(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin"))},this.state.options.animationSpeed)))}canZoomCurrentPhoto(){let e=L(this.state);return!!e&&_(e,T(),O(),this.isSmartPhoneFlag)>1}zoomOutPhoto(){let e=L(this.state),i=this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag&&e?_(e,T(),O(),!0):1;this.state.viewer.scaleSize=i,this.state.viewer.hideUi=i>1,this.state.viewer.scale=i>1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var p,c,f;let o=(p=i.group)!=null?p:this.state.viewer.currentGroup;if(o===null)return;let n=this.state.groups.get(o);if(!(n!=null&&n.length))return;let s=typeof e=="number"?n[e]:n.find(x=>x.id===e);if(!s)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,m=(f=(c=i.trigger)!=null?c:s.element)!=null?f:r;this.openPhoto(s,m)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof HTMLElement?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!lt(e)){e.forEach(o=>{this.addSlideItem(o)});return}Array.from(typeof e=="string"?document.querySelectorAll(e):e).forEach(o=>{this.addElementItem(o)})}addElementItem(e){var s,r;let i=ee(e),o=(r=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?r:0,n=Pe(e,this.state.options,o,T());return be(this.state,n),this.loadAllFired.delete(i),this.itemsByElement.set(e,n),n}addSlideItem(e){var s,r;let i=Ee(e),o=(r=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?r:0,n=Ye(e,o,T());return be(this.state,n),this.loadAllFired.delete(i),n}findRegisteredAncestor(e){let i=e;for(;i;){if(this.itemsByElement.has(i))return i;i=i.parentElement}return null}resyncGroupFromDom(e){var p;if(!this.rootSelector)return!1;let i=Array.from(document.querySelectorAll(this.rootSelector)).filter(c=>ee(c)===e),o=new Set(i),n=(p=this.state.groups.get(e))!=null?p:[],s=new Map;n.forEach(c=>{c.element&&s.set(c.element,c)});let r=i.length!==n.length,m=i.map((c,f)=>{let x=s.get(c);if(x)return x.index!==f&&(r=!0,x.index=f),x;r=!0;let b=Pe(c,this.state.options,f,T());return this.itemsByElement.set(c,b),b});return n.forEach(c=>{c.element&&!o.has(c.element)&&this.itemsByElement.delete(c.element)}),xe(m,T()),this.state.groups.set(e,m),r&&this.loadAllFired.delete(e),r}syncCurrentGroupView(){let e=I(this.state);e&&(this.view.syncSlides(e,this.state),this.syncedGroupId=this.state.viewer.currentGroup)}setHash(e){var o;if(!((o=window.history)!=null&&o.pushState)||!this.state.options.useHistoryApi)return;let i=`${location.pathname}${location.search}`;window.history.replaceState(null,"",e?`${i}#${e}`:i)}setHashByCurrentIndex(){let e=je();this.setHash(We(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?$e(this.state,Ne(e)):null}setPosByCurrentIndex(){let e=L(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=I(this.state);e&&(Ge(e,T(),O(),this.state.options.headerHeight,this.state.options.footerHeight),this.syncFillScale())}resetTranslateCurrent(){xe(I(this.state),T())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}currentLiElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.li;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;e.style.transition=this.state.options.showAnimation===!1?"none":"",this.state.viewer.isOpen&&!e.open?(e.style.removeProperty("display"),e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&(e.close(),e.style.display="none")}commit(e=!1){this.view.render(this.state,{immediate:e}),this.view.updatePhotoTransform(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=I(this.state);this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),Se(this.state)}syncFillScale(){if(this.state.options.resizeStyle!=="fill"||!this.isSmartPhoneFlag)return;let e=L(this.state);e&&(this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=_(e,T(),O(),this.isSmartPhoneFlag))}supportsViewTransition(){return this.state.options.useViewTransitionApi&&typeof document.startViewTransition=="function"&&!Me()}openPhotoWithViewTransition(e){var r,m;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(r=e==null?void 0:e.querySelector("img"))!=null?r:null;o&&(o.style.viewTransitionName=i);let n=()=>{this.isViewTransitionActive=!1,o&&(o.style.viewTransitionName="");let p=this.currentImgElement();if(p&&(p.style.viewTransitionName=""),!this.state.viewer.isOpen){this.pendingViewTransitionResync=!1;return}if(this.pendingViewTransitionResync&&I(this.state)){this.pendingViewTransitionResync=!1,this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit(!0);return}this.pendingViewTransitionResync=!1,this.view.resetViewTransitionLayout()},s=(m=document.startViewTransition)==null?void 0:m.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i,this.view.applyViewTransitionLayout(this.state)});s&&(this.isViewTransitionActive=!0,s.ready.catch(()=>{n()}),s.finished.then(n,n))}addAppearEffect(e,i){var C;let o=(C=e==null?void 0:e.querySelector("img"))!=null?C:null;if(!o){this.state.viewer.appear=!0;return}let n=Be(o),s=o.offsetWidth,r=o.offsetHeight,m=T(),p=O(),c=p-this.state.options.headerHeight-this.state.options.footerHeight,f=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>r?f=p/r:f=m/s:(s>=r?i.height<c?f=i.width/s:f=c/r:i.height<c?f=i.height/r:f=c/r,s*f>m&&(f=m/s));let x=(f-1)/2*s+(m-s*f)/2,b=(f-1)/2*r+(p-r*f)/2,M=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:r,top:n.top,left:n.left,once:!0,img:M||i.src||"",afterX:x,afterY:b,scale:f}}runAppearEffect(e){this.view.showAppearEffect(e);let i=this.view.refs.imgClone;return new Promise(o=>{let n=()=>{i.removeEventListener("transitionend",n,!0),o()};i.addEventListener("transitionend",n,!0),this.scheduleTimeout(()=>{i.style.transform=`translate(${e.afterX}px, ${e.afterY}px) scale(${e.scale})`},10)})}doOpen(e,i){if(this.state.options.showAnimation!==!1&&this.supportsViewTransition())this.openPhotoWithViewTransition(e);else if(this.state.options.showAnimation===!1)this.initPhoto(),this.state.viewer.appear=!0,this.commit();else{this.initPhoto(),this.addAppearEffect(e,i),this.commit();let o=this.state.viewer.appearEffect;o&&this.runAppearEffect(o).then(()=>{this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.appear=!0,this.commit()})}this.fireEvent("open"),this.resyncSizeAfterOpen()}resyncSizeAfterOpen(){let e=T(),i=O();requestAnimationFrame(()=>{if(this.state.viewer.isOpen&&!(T()===e&&O()===i)){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit(!0)}})}openPhoto(e,i){let o=this.resyncGroupFromDom(e.groupId);this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,(this.syncedGroupId!==e.groupId||o)&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{if(this.state.options.showAnimation===!1){i();return}let o=this.view.refs.dialog,n=L(this.state),s=n?this.currentLiElement():null,r=O(),m=this.currentImgElement(),p=null;if(m){let f=getComputedStyle(m).transform;f&&f!=="none"&&(m.style.transform=f,p=m.style.transform)}if(s&&n){let f=e==="top"?-r:r;s.style.transform=`translate(${n.translateX}px,${n.translateY+f}px)`}let c=f=>{this.finishHideEffect===c&&(f&&f.target!==o||(this.finishHideEffect=null,o.removeEventListener("transitionend",c,!0),m&&p&&m.style.transform===p&&(m.style.transform=""),i()))};this.finishHideEffect=c,o.addEventListener("transitionend",c,!0),this.scheduleTimeout(c,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var n;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(n=e.src)!=null?n:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=I(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,n=[];for(let s=i-o;s<i+o;s++){let r=e[s];r&&!r.loaded&&n.push(this.loadItem(r))}n.length&&Promise.all(n).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.updateViewportHeight(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=L(this.state);this.state.viewer.onMove=!1,Se(this.state),this.state.viewer.isOpen&&this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(n=>n!==o),e()},i);return this.timeouts.push(o),o}applyAutoIconContrast(){let e=this.view.refs.dialog,i=getComputedStyle(e);if(i.getPropertyValue("--smartphoto-icon-color").trim())return;let o=i.getPropertyValue("--smartphoto-backdrop-color").trim();o&&e.style.setProperty("--smartphoto-icon-color",De(o))}fireEvent(e){Oe(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:e=>{let i=this.currentImgElement();!!i&&e instanceof Node&&i.contains(e)&&this.canZoomCurrentPhoto()?this.zoomPhoto():this.hidePhoto()},onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},onPinchClose:()=>this.hidePhoto(),onPhotoDragMove:()=>this.view.updatePhotoTransform(this.state),onPhotoDragEnd:e=>{if(e==="zoom-out"){this.zoomOutPhoto();return}if(e==="prev"){this.gotoSlide(this.state.viewer.prev);return}if(e==="next"){this.gotoSlide(this.state.viewer.next);return}this.view.updatePhotoTransform(this.state)}}}};var qe=ie;var Te=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new qe(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],Te);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&Te(e)}var Pt=Te;})();
6
+ "use strict";(()=>{var ae=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},Me=()=>typeof window.webkitConvertPointFromNodeToPage=="function";function Ve(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let n=e[o];if(n){for(let s in n)if(Object.hasOwn(n,s)){let r=n[s];r&&typeof r=="object"?t[s]=Ve((i=t[s])!=null?i:{},r):t[s]=r}}}return t}var ze=Ve,Oe=(t,e,i)=>{let o;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,i)),t.dispatchEvent(o)},Ne=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),n=o[0],s=o.length>1?o.slice(1).join("="):n;e[n]=decodeURIComponent(s)}return e},le=()=>document.documentElement.clientWidth,he=()=>{let t=window.visualViewport;if(t){let e=document.documentElement.clientWidth;return t.width>0&&e>0?t.height*(e/t.width):t.height*t.scale}return document.documentElement.clientHeight},Be=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var He=t=>{let e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/);return e?[Number(e[1]),Number(e[2]),Number(e[3])]:null},tt=.179,it=([t,e,i])=>{let[o,n,s]=[t,e,i].map(r=>{let m=r/255;return m<=.03928?m/12.92:((m+.055)/1.055)**2.4});return .2126*o+.7152*n+.0722*s},De=t=>{let e=t.trim(),i=He(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=He(getComputedStyle(o).color),document.body.removeChild(o)}return i&&it(i)>tt?"#000":"#fff"};var ot={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,useViewTransitionApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,pinchToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:300};function Re(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Re(i)}),Object.freeze(t)}function Xe(t){return{options:Re(ze({},ot,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function ee(t){return t.getAttribute("data-group")||"nogroup"}function Ee(t){return t.group||"nogroup"}function Pe(t,e,i,o){let n=ee(t),s=t.getAttribute("href"),r=t.querySelector("img"),m=s;r&&(r.getAttribute(e.lazyAttribute)?m=r.getAttribute(e.lazyAttribute):r.currentSrc?m=r.currentSrc:m=r.src);let p="";r!=null&&r.getAttribute("alt")?p=r.getAttribute("alt"):t.getAttribute("data-caption")?p=t.getAttribute("data-caption"):p=s!=null?s:"";let c=t.getAttribute("data-id");return{src:s,thumb:m,caption:t.getAttribute("data-caption"),alt:p,groupId:n,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:c||i,loaded:!1,processed:!1,element:t}}function Ye(t,e,i){var c,f,x,b,M;let o=Ee(t),n=t.src,s=(c=t.thumb)!=null?c:n,r=(f=t.caption)!=null?f:null,m=(b=(x=t.alt)!=null?x:r)!=null?b:n,p=typeof t.width=="number"&&typeof t.height=="number";return{src:n,thumb:s,caption:r,alt:m,groupId:o,translateX:i*e,translateY:0,index:e,width:p?t.width:50,height:p?t.height:50,scale:1,x:0,y:0,id:(M=t.id)!=null?M:e,loaded:p,processed:!1,element:null}}function be(t,e){t.groups.has(e.groupId)||t.groups.set(e.groupId,[]),t.groups.get(e.groupId).push(e),t.viewer.currentGroup=e.groupId}function I(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function L(t){var i;let e=I(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function Se(t){let e=I(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,n=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),n!==-1&&(t.viewer.prev=n,t.viewer.showPrevArrow=!0)}function xe(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function ue(t,e){let i=10**e;return Math.round(t*i)/i}function _(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function We(t,e,i,o){let n=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,r,m,p,c;return i>n?(p=(i-n)/2,r=-1*p):(p=(n-i)/2,r=-1*p),o>s?(c=(o-s)/2,m=-1*c):(c=(s-o)/2,m=-1*c),{minX:ue(r,6)/t.scale,minY:ue(m,6)/t.scale,maxX:ue(p,6)/t.scale,maxY:ue(c,6)/t.scale}}var nt=24;function Fe(t,e,i,o,n){let s=i-(o+n)-nt*2;t.forEach(r=>{r.loaded&&(r.processed=!0,r.scale=s/r.height,r.height<s&&(r.scale=1),r.x=(r.scale-1)/2*r.width+(e-r.width*r.scale)/2,r.y=(r.scale-1)/2*r.height+(i-r.height*r.scale)/2,r.width*r.scale>e&&(r.scale=e/r.width,r.x=(r.scale-1)/2*r.width))})}function Ge(t){let e=L(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function $e(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(n=>{e.group===n.groupId&&e.photo===n.id&&(i=n)})}),i}function te(t,e){let i=10**e;return Math.round(t*i)/i}function K(t){return{x:t.clientX,y:t.clientY}}function ke(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var rt=10;function st(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ie(){return{width:le(),height:he()}}function Ue({state:t,callbacks:e},{signal:i}){let o=new Map,n=Date.now(),s=!1,r=!1,m=null,p=null,c=null,f=0,x=null,b=!1,M=null,C=null,N=0,G=0,z=!1,B=0,D=1,V=null,u=0,R=0;function j(){return ae()}function q(a){let{width:h,height:w}=Ie();return We(a,t.viewer,h,w)}function oe(a){let{width:h,height:w}=Ie();return _(a,h,w,j())}function $(a){return t.options.resizeStyle==="fill"&&j()?oe(a):1}let ne=4;function de(a){return Math.max(ne,oe(a))}let me=.75;function re(a,h){let w=L(t),g=q(w);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=g.minX:a===-1&&(t.viewer.photoPosX=g.maxX),h===1?t.viewer.photoPosY=g.minY:h===-1&&(t.viewer.photoPosY=g.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let pe=setInterval(()=>{if(z||s||b||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=u,t.viewer.photoPosY+=R;let a=L(t);if(!a)return;let h=q(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,u*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,u*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,R*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,R*=-.2);let w=st(u,R),g=w.force-t.options.registance;g<.5||(u=Math.cos(w.theta)*g,R=Math.sin(w.theta)*g,e.onPhotoDragMove())},t.options.forceInterval);function Q(a,h){(a>5||a<-5)&&(u+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(R+=h*.05)}function fe(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||z||s||b||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?Q(a.gamma,a.beta):h===90?Q(a.beta,a.gamma):h===-90?Q(-a.beta,-a.gamma):h===180&&Q(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",fe,{signal:i});function se(){let a=Array.from(o.values());B=ke(a[0],a[1]),D=t.viewer.scaleSize}function ve(){z=!0,s=!1,b=!1,se(),u=0,R=0,t.viewer.scale=!0,t.viewer.hideUi=!0,e.onGestureStart()}function d(a){let h=K(a);s=!0,r=!0,m=h,p=h,f=Date.now(),x=a.target}function l(a){b=!0;let h=K(a);C=h,M=h}function v(a){var h,w;try{(w=(h=a.currentTarget).setPointerCapture)==null||w.call(h,a.pointerId)}catch(g){}if(o.set(a.pointerId,K(a)),o.size>1){ve();return}if(t.viewer.scale){l(a);return}d(a)}function y(){V===null&&(V=requestAnimationFrame(()=>{V=null,e.onGestureMove()}))}function P(){V!==null&&(cancelAnimationFrame(V),V=null,e.onGestureMove())}function E(){let a=Array.from(o.values()),h=a[0],w=a[1],g=ke(h,w);if(B===0){B=g,D=t.viewer.scaleSize,y();return}let S=t.viewer.scaleSize;t.viewer.scaleSize=te(D*g/B,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2);let H=L(t);if(H&&t.viewer.scaleSize!==S){let{width:F,height:ge}=Ie(),Z=F/2,Y=t.options.headerHeight+(ge-t.options.headerHeight-t.options.footerHeight)/2,J=H.scale,U={x:(h.x+w.x)/2,y:(h.y+w.y)/2},Ae=t.viewer.scaleSize/S,Ze=U.x-(Z+t.viewer.photoPosX*J),et=U.y-(Y+t.viewer.photoPosY*J);t.viewer.photoPosX=te((U.x-Ze*Ae-Z)/J,6),t.viewer.photoPosY=te((U.y-et*Ae-Y)/J,6)}y()}function A(a){let h=K(a),w=h.x-p.x,g=h.y-m.y;r&&(e.onSwipeStart(),r=!1,c=Math.abs(w)>Math.abs(g)?"horizontal":"vertical"),c==="horizontal"?t.viewer.translateX+=w:t.viewer.translateY=g,p=h,e.onSwipeMove()}function k(a){let h=K(a),w=h.x-C.x,g=h.y-C.y,S=te(t.viewer.scaleSize*w,6),H=te(t.viewer.scaleSize*g,6);t.viewer.photoPosX+=S,N=S,t.viewer.photoPosY+=H,G=H,C=h,e.onPhotoDragMove()}function X(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,K(a)),z){E();return}if(b){k(a);return}A(a)}}function W(){z=!1,P();let a=L(t);if(!a)return;let h=$(a);if(t.viewer.scaleSize<=h){if(t.options.pinchToClose&&t.viewer.scaleSize<h*me){e.onPinchClose();return}t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scaleSize=h,t.viewer.scale=h>1,t.viewer.hideUi=h>1,e.onGestureEnd();return}t.viewer.scaleSize=Math.min(t.viewer.scaleSize,de(a));let w=q(a),g=0,S=0;t.viewer.photoPosX>w.maxX?g=-1:t.viewer.photoPosX<w.minX&&(g=1),t.viewer.photoPosY>w.maxY?S=-1:t.viewer.photoPosY<w.minY&&(S=1),(g!==0||S!==0)&&re(g,S),t.viewer.scale=!0,t.viewer.hideUi=!0,e.onGestureEnd()}function we(){var Z;s=!1;let a=m,h=p,w=Date.now(),g=n-w,S=h.x-a.x,H=h.y-a.y,F=S===0&&H===0;if(!j()&&F){e.onTap(x);return}if(Math.abs(g)<=500&&F){e.onTap(x);return}n=w;let ge=(Z=I(t))!=null?Z:[];if(c==="horizontal"){let Y="stay",J=Math.max(w-f,1),U=Math.abs(S)>=rt&&Math.abs(S)/J>=t.options.swipeVelocity;(S>=t.options.swipeOffset||U&&S>0)&&t.viewer.currentIndex!==0?Y="prev":(S<=-t.options.swipeOffset||U&&S<0)&&t.viewer.currentIndex!==ge.length-1&&(Y="next"),e.onSwipeEnd(Y)}else{let Y="stay";t.options.swipeBottomToClose&&H>=t.options.swipeOffset?Y="close-bottom":t.options.swipeTopToClose&&H<=-t.options.swipeOffset&&(Y="close-top"),e.onSwipeEnd(Y)}}function Qe(){b=!1;let a=C,h=M;if(a.x===h.x&&a.y===h.y){e.onPhotoDragEnd("zoom-out");return}let w=L(t);if(!w){e.onPhotoDragEnd(null);return}let g=q(w),S=t.options.swipeOffset*t.viewer.scaleSize,H=0,F=0;if(t.viewer.photoPosX>g.maxX?H=-1:t.viewer.photoPosX<g.minX&&(H=1),t.viewer.photoPosY>g.maxY?F=-1:t.viewer.photoPosY<g.minY&&(F=1),t.viewer.photoPosX-g.maxX>S&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(g.minX-t.viewer.photoPosX>S&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}H===0&&F===0?(u=N/5,R=G/5):re(H,F),e.onPhotoDragEnd(null)}function Ce(a){if(o.delete(a.pointerId),z){o.size<2?(W(),o.clear()):se();return}if(b){Qe();return}s&&we()}function Je(...a){for(let h of a)h.addEventListener("pointerdown",v,{signal:i}),h.addEventListener("pointermove",X,{signal:i}),h.addEventListener("pointerup",Ce,{signal:i}),h.addEventListener("pointercancel",Ce,{signal:i})}function Ke(){clearInterval(pe),V!==null&&(cancelAnimationFrame(V),V=null)}return{attach:Je,detach:Ke}}function ce(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function Le(){let t=document.createElement("button");return t.type="button",t}function at(t){return t.replace(/"/g,'\\"')}function _e({id:t,options:e},i,{signal:o}){let{classNames:n,message:s}=e,r=document.createElement("div");r.setAttribute("data-id",t);let m=document.createElement("dialog");m.className=n.smartPhoto,m.setAttribute("aria-labelledby",`smartphoto-${t}-title`),m.style.display="none",m.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=n.smartPhotoBody;let c=document.createElement("div");c.className=n.smartPhotoInner;let f=document.createElement("div");f.className=n.smartPhotoHeader;let x=document.createElement("span");x.className=n.smartPhotoCount;let b=document.createElement("h1");b.id=`smartphoto-${t}-title`,b.className=n.smartPhotoCaption,b.setAttribute("tabindex","-1");let M=document.createElement("button");M.className=n.smartPhotoDismiss,M.appendChild(ce(s.closeDialog)),M.addEventListener("click",()=>i.onDismiss(),{signal:o}),f.append(x,b,M);let C=document.createElement("div");C.className=n.smartPhotoContent,C.addEventListener("click",d=>{d.target===C&&i.onBackdropClick()},{signal:o});let N=document.createElement("ul");N.className=n.smartPhotoList,N.setAttribute("role","region"),N.setAttribute("aria-roledescription","carousel"),N.setAttribute("aria-label",s.carouselLabel),N.setAttribute("aria-live","polite"),N.setAttribute("aria-atomic","false"),c.append(f,C,N);let G=null,z=null,B=null;if(e.arrows){G=document.createElement("ul"),G.className=n.smartPhotoArrows,z=document.createElement("li"),z.className=n.smartPhotoArrowLeft;let d=Le();d.appendChild(ce(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),z.appendChild(d),B=document.createElement("li"),B.className=n.smartPhotoArrowRight;let l=Le();l.appendChild(ce(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),B.appendChild(l),G.append(z,B),c.appendChild(G)}let D=null,V=null;e.nav&&(D=document.createElement("nav"),D.className=n.smartPhotoNav,D.setAttribute("aria-label","Choose slide to display"),V=document.createElement("ul"),D.appendChild(V),c.appendChild(D)),p.appendChild(c),m.appendChild(p),r.appendChild(m);let u={dialog:m,count:x,caption:b,dismiss:M,content:C,list:N,arrows:G,arrowLeft:z,arrowRight:B,nav:D,navList:V,slides:new Map,imgClone:null};function R(){let d=document.createElement("div");d.className=n.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=n.smartPhotoLoader,d.appendChild(l),d}function j(d){var y,P;let l=document.createElement("div");l.className=n.smartPhotoImgWrap;let v=document.createElement("img");return v.className=n.smartPhotoImg,v.src=(y=d.src)!=null?y:"",v.alt=(P=d.alt)!=null?P:"",v.addEventListener("dragstart",E=>E.preventDefault(),{signal:o}),l.appendChild(v),{imgWrap:l,img:v}}function q(d,l){var v;u.list.replaceChildren(),(v=u.navList)==null||v.replaceChildren(),u.slides=new Map,d.forEach(y=>{var A,k;let P=document.createElement("li");P.setAttribute("role","group"),P.setAttribute("aria-roledescription","slide"),P.setAttribute("aria-label",`${y.index+1} of ${d.length}`);let E={li:P,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(y.processed){let{imgWrap:X,img:W}=j(y);P.appendChild(X),E.imgWrap=X,E.img=W}else{let X=R();P.appendChild(X),E.loaderWrap=X}if(u.list.appendChild(P),u.slides.set(y,E),u.navList){let X=document.createElement("li"),W=Le();W.style.backgroundImage=`url("${at((A=y.thumb)!=null?A:"")}")`;let we=y.index;W.addEventListener("click",()=>i.onNavigate(we),{signal:o}),W.appendChild(ce(`go to ${(k=y.caption)!=null?k:""}`)),X.appendChild(W),u.navList.appendChild(X),E.navLink=W}}),ne(l)}function oe(d,l){var P;if(l.imgWrap||!d.processed)return l;let{imgWrap:v,img:y}=j(d);return(P=l.loaderWrap)==null||P.replaceWith(v),l.loaderWrap=null,l.imgWrap=v,l.img=y,l}function $(d){d&&document.activeElement&&d.contains(document.activeElement)&&u.caption.focus()}function ne(d,l){let{viewer:v}=d;u.count.textContent=`${v.currentIndex+1}/${v.total}`,u.slides.forEach((y,P)=>{var k;let E=oe(P,y),A=P.index===v.currentIndex;E.li.style.transition=l!=null&&l.immediate?"none":"",E.li.style.transform=`translate(${P.translateX}px,${P.translateY}px)`,E.li.classList.toggle("current",A),A?E.li.removeAttribute("aria-hidden"):E.li.setAttribute("aria-hidden","true"),A&&(u.caption.textContent=(k=P.caption)!=null?k:""),E.imgWrap&&E.img&&(E.imgWrap.style.transform=`translate(${P.x}px,${P.y}px) scale(${P.scale})`,E.img.style.width=`${P.width}px`,A||(E.img.style.transform="translate(0px,0px) scale(1)"),E.img.classList.toggle("active",v.appear),E.img.classList.toggle(n.smartPhotoImgOnMove,v.scale),E.img.classList.toggle(n.smartPhotoImgElasticMove,v.elastic)),E.navLink&&(E.navLink.classList.toggle("current",A),A?E.navLink.setAttribute("aria-current","true"):E.navLink.removeAttribute("aria-current"))}),u.arrowLeft&&(v.showPrevArrow?u.arrowLeft.removeAttribute("aria-hidden"):($(u.arrowLeft),u.arrowLeft.setAttribute("aria-hidden","true"))),u.arrowRight&&(v.showNextArrow?u.arrowRight.removeAttribute("aria-hidden"):($(u.arrowRight),u.arrowRight.setAttribute("aria-hidden","true"))),u.arrows&&(v.hideUi&&$(u.arrows),u.arrows.setAttribute("aria-hidden",v.hideUi?"true":"false")),u.nav&&(v.hideUi&&$(u.nav),u.nav.setAttribute("aria-hidden",v.hideUi?"true":"false"))}function de(d){for(let[l,v]of u.slides)if(l.index===d.viewer.currentIndex)return v;return null}function me(d){let{viewer:l}=d,v=de(d),y=v==null?void 0:v.img;y&&(y.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,y.classList.toggle(n.smartPhotoImgOnMove,l.scale),y.classList.toggle(n.smartPhotoImgElasticMove,l.elastic)),u.nav&&(l.hideUi&&$(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.arrows&&(l.hideUi&&$(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function re(d){let{viewer:l}=d;u.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,u.list.classList.toggle(n.smartPhotoListOnMove,l.onMove)}function pe(d){for(let[l,v]of u.slides){if(l.index!==d.viewer.currentIndex)continue;let{img:y,imgWrap:P}=v;if(!y||!P||!l.width||!l.scale||l.scale>=1)return;let E=y.getBoundingClientRect();y.style.width=`${l.width*l.scale}px`,P.style.transform=`translate(${l.x}px,${l.y}px) scale(1)`;let A=y.getBoundingClientRect();P.style.transform=`translate(${l.x+E.left-A.left}px,${l.y+E.top-A.top}px) scale(1)`;return}}function Q(){for(let[d,l]of u.slides){let{img:v,imgWrap:y}=l;v&&y&&(y.style.transform=`translate(${d.x}px,${d.y}px) scale(${d.scale})`,v.style.width=`${d.width}px`)}}function fe(d){let l=document.createElement("img");l.className=n.smartPhotoImgClone,l.src=d.img,l.style.width=`${d.width}px`,l.style.height=`${d.height}px`,l.style.transform=`translate(${d.left}px,${d.top}px) scale(1)`,p.appendChild(l),u.imgClone=l}function se(){var d;(d=u.imgClone)==null||d.remove(),u.imgClone=null}function ve(){r.remove()}return{root:r,refs:u,render:ne,syncSlides:q,updatePhotoTransform:me,applyViewTransitionLayout:pe,resetViewTransitionLayout:Q,updateListTransform:re,showAppearEffect:fe,removeAppearEffect:se,destroy:ve}}var T=le,O=he;function lt(t){return t.length>0&&t[0]instanceof Element}function ht(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function je(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var ie=class{constructor(e,i){this.id=ht();this.abortController=new AbortController;this.isSmartPhoneFlag=ae();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.isViewTransitionActive=!1;this.pendingViewTransitionResync=!1;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.rootSelector=null;this.itemsByElement=new Map;this.handleDocumentClick=e=>{if(!(e.target instanceof Element))return;let i=e;if(i.__smartphotoClaimed)return;let o=this.findRegisteredAncestor(e.target);if(!o&&this.rootSelector&&(o=e.target.closest(this.rootSelector)),!o)return;if(e.preventDefault(),i.__smartphotoClaimed=!0,!this.itemsByElement.has(o)&&this.rootSelector){let s=ee(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let n=this.itemsByElement.get(o);n&&this.openPhoto(n,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${O()}px`)};this.handleVisualViewportResize=()=>{if(this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!I(this.state))){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit(!0)}};this.handleResize=()=>{if(!(!this.state.viewer.isOpen||!I(this.state))){if(this.updateViewportHeight(),this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit(!0)}};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!this.state.viewer.isOpen||!I(this.state))return;if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit(!0);let e=T(),i=O(),o=500,n=s=>{this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(e!==T()||i!==O()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit(!0)):s<=o&&n(s+25))},25)};n(0)};this.rootSelector=typeof e=="string"?e:null,this.state=Xe(i!=null?i:{}),this.view=_e({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Ue({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),document.addEventListener("click",this.handleDocumentClick,{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&this.openPhoto(o,o.element),this.updateViewportHeight(),this.applyAutoIconContrast(),window.visualViewport?window.visualViewport.addEventListener("resize",this.handleVisualViewportResize,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,n=s=>i.call(o,s);o.addEventListener(e,n,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.itemsByElement.clear(),this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){var s,r;let i=Number.parseInt(String(e),10),o=Number.isNaN(i)?0:i,n=(r=(s=I(this.state))==null?void 0:s.length)!=null?r:0;o<0||o>=n||(this.state.viewer.currentIndex=o,this.slideList())}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=je();location.hash&&this.setHash(""),window.scroll(i.x,i.y),this.syncDialog(),(o=this.lastTriggerElement)!=null&&o.isConnected&&this.lastTriggerElement.focus(),this.lastTriggerElement=null,this.doHideEffect(e).then(()=>{this.view.render(this.state),this.isFiringPublicCloseEvent=!0,this.fireEvent("close"),this.isFiringPublicCloseEvent=!1})}zoomPhoto(){let e=L(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=_(e,T(),O(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin"))},this.state.options.animationSpeed)))}canZoomCurrentPhoto(){let e=L(this.state);return!!e&&_(e,T(),O(),this.isSmartPhoneFlag)>1}zoomOutPhoto(){let e=L(this.state),i=this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag&&e?_(e,T(),O(),!0):1;this.state.viewer.scaleSize=i,this.state.viewer.hideUi=i>1,this.state.viewer.scale=i>1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var p,c,f;let o=(p=i.group)!=null?p:this.state.viewer.currentGroup;if(o===null)return;let n=this.state.groups.get(o);if(!(n!=null&&n.length))return;let s=typeof e=="number"?n[e]:n.find(x=>x.id===e);if(!s)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,m=(f=(c=i.trigger)!=null?c:s.element)!=null?f:r;this.openPhoto(s,m)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof HTMLElement?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!lt(e)){e.forEach(o=>{this.addSlideItem(o)});return}Array.from(typeof e=="string"?document.querySelectorAll(e):e).forEach(o=>{this.addElementItem(o)})}addElementItem(e){var s,r;let i=ee(e),o=(r=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?r:0,n=Pe(e,this.state.options,o,T());return be(this.state,n),this.loadAllFired.delete(i),this.itemsByElement.set(e,n),n}addSlideItem(e){var s,r;let i=Ee(e),o=(r=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?r:0,n=Ye(e,o,T());return be(this.state,n),this.loadAllFired.delete(i),n}findRegisteredAncestor(e){let i=e;for(;i;){if(this.itemsByElement.has(i))return i;i=i.parentElement}return null}resyncGroupFromDom(e){var p;if(!this.rootSelector)return!1;let i=Array.from(document.querySelectorAll(this.rootSelector)).filter(c=>ee(c)===e),o=new Set(i),n=(p=this.state.groups.get(e))!=null?p:[],s=new Map;n.forEach(c=>{c.element&&s.set(c.element,c)});let r=i.length!==n.length,m=i.map((c,f)=>{let x=s.get(c);if(x)return x.index!==f&&(r=!0,x.index=f),x;r=!0;let b=Pe(c,this.state.options,f,T());return this.itemsByElement.set(c,b),b});return n.forEach(c=>{c.element&&!o.has(c.element)&&this.itemsByElement.delete(c.element)}),xe(m,T()),this.state.groups.set(e,m),r&&this.loadAllFired.delete(e),r}syncCurrentGroupView(){let e=I(this.state);e&&(this.view.syncSlides(e,this.state),this.syncedGroupId=this.state.viewer.currentGroup)}setHash(e){var o;if(!((o=window.history)!=null&&o.pushState)||!this.state.options.useHistoryApi)return;let i=`${location.pathname}${location.search}`;window.history.replaceState(null,"",e?`${i}#${e}`:i)}setHashByCurrentIndex(){let e=je();this.setHash(Ge(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?$e(this.state,Ne(e)):null}setPosByCurrentIndex(){let e=L(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=I(this.state);e&&(Fe(e,T(),O(),this.state.options.headerHeight,this.state.options.footerHeight),this.syncFillScale())}resetTranslateCurrent(){xe(I(this.state),T())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}currentLiElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.li;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;e.style.transition=this.state.options.showAnimation===!1?"none":"",this.state.viewer.isOpen&&!e.open?(e.style.removeProperty("display"),e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&(e.close(),e.style.display="none")}commit(e=!1){this.view.render(this.state,{immediate:e}),this.view.updatePhotoTransform(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=I(this.state);this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),Se(this.state)}syncFillScale(){if(this.state.options.resizeStyle!=="fill"||!this.isSmartPhoneFlag)return;let e=L(this.state);e&&(this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=_(e,T(),O(),this.isSmartPhoneFlag))}supportsViewTransition(){return this.state.options.useViewTransitionApi&&typeof document.startViewTransition=="function"&&!Me()}openPhotoWithViewTransition(e){var r,m;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(r=e==null?void 0:e.querySelector("img"))!=null?r:null;o&&(o.style.viewTransitionName=i);let n=()=>{this.isViewTransitionActive=!1,o&&(o.style.viewTransitionName="");let p=this.currentImgElement();if(p&&(p.style.viewTransitionName=""),!this.state.viewer.isOpen){this.pendingViewTransitionResync=!1;return}if(this.pendingViewTransitionResync&&I(this.state)){this.pendingViewTransitionResync=!1,this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit(!0);return}this.pendingViewTransitionResync=!1,this.view.resetViewTransitionLayout()},s=(m=document.startViewTransition)==null?void 0:m.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i,this.view.applyViewTransitionLayout(this.state)});s&&(this.isViewTransitionActive=!0,s.ready.catch(()=>{n()}),s.finished.then(n,n))}addAppearEffect(e,i){var C;let o=(C=e==null?void 0:e.querySelector("img"))!=null?C:null;if(!o){this.state.viewer.appear=!0;return}let n=Be(o),s=o.offsetWidth,r=o.offsetHeight,m=T(),p=O(),c=p-this.state.options.headerHeight-this.state.options.footerHeight,f=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>r?f=p/r:f=m/s:(s>=r?i.height<c?f=i.width/s:f=c/r:i.height<c?f=i.height/r:f=c/r,s*f>m&&(f=m/s));let x=(f-1)/2*s+(m-s*f)/2,b=(f-1)/2*r+(p-r*f)/2,M=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:r,top:n.top,left:n.left,once:!0,img:M||i.src||"",afterX:x,afterY:b,scale:f}}runAppearEffect(e){this.view.showAppearEffect(e);let i=this.view.refs.imgClone;return new Promise(o=>{let n=()=>{i.removeEventListener("transitionend",n,!0),o()};i.addEventListener("transitionend",n,!0),this.scheduleTimeout(()=>{i.style.transform=`translate(${e.afterX}px, ${e.afterY}px) scale(${e.scale})`},10)})}doOpen(e,i){if(this.state.options.showAnimation!==!1&&this.supportsViewTransition())this.openPhotoWithViewTransition(e);else if(this.state.options.showAnimation===!1)this.initPhoto(),this.state.viewer.appear=!0,this.commit();else{this.initPhoto(),this.addAppearEffect(e,i),this.commit();let o=this.state.viewer.appearEffect;o&&this.runAppearEffect(o).then(()=>{this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.appear=!0,this.commit()})}this.fireEvent("open"),this.resyncSizeAfterOpen()}resyncSizeAfterOpen(){let e=T(),i=O();requestAnimationFrame(()=>{if(this.state.viewer.isOpen&&!(T()===e&&O()===i)){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit(!0)}})}openPhoto(e,i){let o=this.resyncGroupFromDom(e.groupId);this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,(this.syncedGroupId!==e.groupId||o)&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{if(this.state.options.showAnimation===!1){i();return}let o=this.view.refs.dialog,n=L(this.state),s=n?this.currentLiElement():null,r=O(),m=this.currentImgElement(),p=null;if(m){let f=getComputedStyle(m).transform;f&&f!=="none"&&(m.style.transform=f,p=m.style.transform)}if(s&&n){let f=e==="top"?-r:r;s.style.transform=`translate(${n.translateX}px,${n.translateY+f}px)`}let c=f=>{this.finishHideEffect===c&&(f&&f.target!==o||(this.finishHideEffect=null,o.removeEventListener("transitionend",c,!0),m&&p&&m.style.transform===p&&(m.style.transform=""),i()))};this.finishHideEffect=c,o.addEventListener("transitionend",c,!0),this.scheduleTimeout(c,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var n;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(n=e.src)!=null?n:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=I(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,n=[];for(let s=i-o;s<i+o;s++){let r=e[s];r&&!r.loaded&&n.push(this.loadItem(r))}n.length&&Promise.all(n).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.updateViewportHeight(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=L(this.state);this.state.viewer.onMove=!1,Se(this.state),this.state.viewer.isOpen&&this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(n=>n!==o),e()},i);return this.timeouts.push(o),o}applyAutoIconContrast(){let e=this.view.refs.dialog,i=getComputedStyle(e);if(i.getPropertyValue("--smartphoto-icon-color").trim())return;let o=i.getPropertyValue("--smartphoto-backdrop-color").trim();o&&e.style.setProperty("--smartphoto-icon-color",De(o))}fireEvent(e){Oe(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:e=>{let i=this.currentImgElement();!!i&&e instanceof Node&&i.contains(e)&&this.canZoomCurrentPhoto()?this.zoomPhoto():this.hidePhoto()},onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},onPinchClose:()=>this.hidePhoto(),onPhotoDragMove:()=>this.view.updatePhotoTransform(this.state),onPhotoDragEnd:e=>{if(e==="zoom-out"){this.zoomOutPhoto();return}if(e==="prev"){this.gotoSlide(this.state.viewer.prev);return}if(e==="next"){this.gotoSlide(this.state.viewer.next);return}this.view.updatePhotoTransform(this.state)}}}};var qe=ie;var Te=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new qe(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],Te);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&Te(e)}var Pt=Te;})();
package/js/smartphoto.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * SmartPhoto v2.1.17
2
+ * SmartPhoto v2.1.18
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
@@ -88,6 +88,10 @@ var SmartPhoto = (() => {
88
88
  var getWindowHeight = () => {
89
89
  const visualViewport = window.visualViewport;
90
90
  if (visualViewport) {
91
+ const layoutWidth = document.documentElement.clientWidth;
92
+ if (visualViewport.width > 0 && layoutWidth > 0) {
93
+ return visualViewport.height * (layoutWidth / visualViewport.width);
94
+ }
91
95
  return visualViewport.height * visualViewport.scale;
92
96
  }
93
97
  return document.documentElement.clientHeight;
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * SmartPhoto v2.1.17
2
+ * SmartPhoto v2.1.18
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
6
- "use strict";var SmartPhoto=(()=>{var ye=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var it=Object.prototype.hasOwnProperty;var ot=(t,e)=>{for(var i in e)ye(t,i,{get:e[i],enumerable:!0})},nt=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of tt(e))!it.call(t,n)&&n!==i&&ye(t,n,{get:()=>e[n],enumerable:!(o=et(e,n))||o.enumerable});return t};var rt=t=>nt(ye({},"__esModule",{value:!0}),t);var vt={};ot(vt,{default:()=>ft});var ae=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},Me=()=>typeof window.webkitConvertPointFromNodeToPage=="function";function Ve(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let n=e[o];if(n){for(let s in n)if(Object.hasOwn(n,s)){let r=n[s];r&&typeof r=="object"?t[s]=Ve((i=t[s])!=null?i:{},r):t[s]=r}}}return t}var ze=Ve,Oe=(t,e,i)=>{let o;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,i)),t.dispatchEvent(o)},Ne=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),n=o[0],s=o.length>1?o.slice(1).join("="):n;e[n]=decodeURIComponent(s)}return e},le=()=>document.documentElement.clientWidth,he=()=>{let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight},Be=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var He=t=>{let e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/);return e?[Number(e[1]),Number(e[2]),Number(e[3])]:null},st=.179,at=([t,e,i])=>{let[o,n,s]=[t,e,i].map(r=>{let m=r/255;return m<=.03928?m/12.92:((m+.055)/1.055)**2.4});return .2126*o+.7152*n+.0722*s},De=t=>{let e=t.trim(),i=He(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=He(getComputedStyle(o).color),document.body.removeChild(o)}return i&&at(i)>st?"#000":"#fff"};var lt={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,useViewTransitionApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,pinchToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:300};function Xe(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Xe(i)}),Object.freeze(t)}function Re(t){return{options:Xe(ze({},lt,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function ee(t){return t.getAttribute("data-group")||"nogroup"}function Pe(t){return t.group||"nogroup"}function be(t,e,i,o){let n=ee(t),s=t.getAttribute("href"),r=t.querySelector("img"),m=s;r&&(r.getAttribute(e.lazyAttribute)?m=r.getAttribute(e.lazyAttribute):r.currentSrc?m=r.currentSrc:m=r.src);let p="";r!=null&&r.getAttribute("alt")?p=r.getAttribute("alt"):t.getAttribute("data-caption")?p=t.getAttribute("data-caption"):p=s!=null?s:"";let c=t.getAttribute("data-id");return{src:s,thumb:m,caption:t.getAttribute("data-caption"),alt:p,groupId:n,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:c||i,loaded:!1,processed:!1,element:t}}function Ye(t,e,i){var c,f,x,b,M;let o=Pe(t),n=t.src,s=(c=t.thumb)!=null?c:n,r=(f=t.caption)!=null?f:null,m=(b=(x=t.alt)!=null?x:r)!=null?b:n,p=typeof t.width=="number"&&typeof t.height=="number";return{src:n,thumb:s,caption:r,alt:m,groupId:o,translateX:i*e,translateY:0,index:e,width:p?t.width:50,height:p?t.height:50,scale:1,x:0,y:0,id:(M=t.id)!=null?M:e,loaded:p,processed:!1,element:null}}function Se(t,e){t.groups.has(e.groupId)||t.groups.set(e.groupId,[]),t.groups.get(e.groupId).push(e),t.viewer.currentGroup=e.groupId}function I(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function T(t){var i;let e=I(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function xe(t){let e=I(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,n=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),n!==-1&&(t.viewer.prev=n,t.viewer.showPrevArrow=!0)}function Ie(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function ue(t,e){let i=10**e;return Math.round(t*i)/i}function _(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Fe(t,e,i,o){let n=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,r,m,p,c;return i>n?(p=(i-n)/2,r=-1*p):(p=(n-i)/2,r=-1*p),o>s?(c=(o-s)/2,m=-1*c):(c=(s-o)/2,m=-1*c),{minX:ue(r,6)/t.scale,minY:ue(m,6)/t.scale,maxX:ue(p,6)/t.scale,maxY:ue(c,6)/t.scale}}var ht=24;function Ge(t,e,i,o,n){let s=i-(o+n)-ht*2;t.forEach(r=>{r.loaded&&(r.processed=!0,r.scale=s/r.height,r.height<s&&(r.scale=1),r.x=(r.scale-1)/2*r.width+(e-r.width*r.scale)/2,r.y=(r.scale-1)/2*r.height+(i-r.height*r.scale)/2,r.width*r.scale>e&&(r.scale=e/r.width,r.x=(r.scale-1)/2*r.width))})}function We(t){let e=T(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function $e(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(n=>{e.group===n.groupId&&e.photo===n.id&&(i=n)})}),i}function te(t,e){let i=10**e;return Math.round(t*i)/i}function Z(t){return{x:t.clientX,y:t.clientY}}function ke(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var ut=10;function ct(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Te(){return{width:le(),height:he()}}function Ue({state:t,callbacks:e},{signal:i}){let o=new Map,n=Date.now(),s=!1,r=!1,m=null,p=null,c=null,f=0,x=null,b=!1,M=null,C=null,N=0,W=0,z=!1,B=0,D=1,V=null,u=0,X=0;function q(){return ae()}function j(a){let{width:h,height:w}=Te();return Fe(a,t.viewer,h,w)}function oe(a){let{width:h,height:w}=Te();return _(a,h,w,q())}function $(a){return t.options.resizeStyle==="fill"&&q()?oe(a):1}let ne=4;function de(a){return Math.max(ne,oe(a))}let me=.75;function re(a,h){let w=T(t),g=j(w);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=g.minX:a===-1&&(t.viewer.photoPosX=g.maxX),h===1?t.viewer.photoPosY=g.minY:h===-1&&(t.viewer.photoPosY=g.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let pe=setInterval(()=>{if(z||s||b||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=u,t.viewer.photoPosY+=X;let a=T(t);if(!a)return;let h=j(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,u*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,u*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,X*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,X*=-.2);let w=ct(u,X),g=w.force-t.options.registance;g<.5||(u=Math.cos(w.theta)*g,X=Math.sin(w.theta)*g,e.onPhotoDragMove())},t.options.forceInterval);function K(a,h){(a>5||a<-5)&&(u+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(X+=h*.05)}function fe(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||z||s||b||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?K(a.gamma,a.beta):h===90?K(a.beta,a.gamma):h===-90?K(-a.beta,-a.gamma):h===180&&K(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",fe,{signal:i});function se(){let a=Array.from(o.values());B=ke(a[0],a[1]),D=t.viewer.scaleSize}function ve(){z=!0,s=!1,b=!1,se(),u=0,X=0,t.viewer.scale=!0,t.viewer.hideUi=!0,e.onGestureStart()}function d(a){let h=Z(a);s=!0,r=!0,m=h,p=h,f=Date.now(),x=a.target}function l(a){b=!0;let h=Z(a);C=h,M=h}function v(a){var h,w;try{(w=(h=a.currentTarget).setPointerCapture)==null||w.call(h,a.pointerId)}catch(g){}if(o.set(a.pointerId,Z(a)),o.size>1){ve();return}if(t.viewer.scale){l(a);return}d(a)}function y(){V===null&&(V=requestAnimationFrame(()=>{V=null,e.onGestureMove()}))}function P(){V!==null&&(cancelAnimationFrame(V),V=null,e.onGestureMove())}function E(){let a=Array.from(o.values()),h=a[0],w=a[1],g=ke(h,w);if(B===0){B=g,D=t.viewer.scaleSize,y();return}let S=t.viewer.scaleSize;t.viewer.scaleSize=te(D*g/B,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2);let H=T(t);if(H&&t.viewer.scaleSize!==S){let{width:G,height:ge}=Te(),J=G/2,Y=t.options.headerHeight+(ge-t.options.headerHeight-t.options.footerHeight)/2,Q=H.scale,U={x:(h.x+w.x)/2,y:(h.y+w.y)/2},Ae=t.viewer.scaleSize/S,Ze=U.x-(J+t.viewer.photoPosX*Q),Je=U.y-(Y+t.viewer.photoPosY*Q);t.viewer.photoPosX=te((U.x-Ze*Ae-J)/Q,6),t.viewer.photoPosY=te((U.y-Je*Ae-Y)/Q,6)}y()}function A(a){let h=Z(a),w=h.x-p.x,g=h.y-m.y;r&&(e.onSwipeStart(),r=!1,c=Math.abs(w)>Math.abs(g)?"horizontal":"vertical"),c==="horizontal"?t.viewer.translateX+=w:t.viewer.translateY=g,p=h,e.onSwipeMove()}function k(a){let h=Z(a),w=h.x-C.x,g=h.y-C.y,S=te(t.viewer.scaleSize*w,6),H=te(t.viewer.scaleSize*g,6);t.viewer.photoPosX+=S,N=S,t.viewer.photoPosY+=H,W=H,C=h,e.onPhotoDragMove()}function R(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,Z(a)),z){E();return}if(b){k(a);return}A(a)}}function F(){z=!1,P();let a=T(t);if(!a)return;let h=$(a);if(t.viewer.scaleSize<=h){if(t.options.pinchToClose&&t.viewer.scaleSize<h*me){e.onPinchClose();return}t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scaleSize=h,t.viewer.scale=h>1,t.viewer.hideUi=h>1,e.onGestureEnd();return}t.viewer.scaleSize=Math.min(t.viewer.scaleSize,de(a));let w=j(a),g=0,S=0;t.viewer.photoPosX>w.maxX?g=-1:t.viewer.photoPosX<w.minX&&(g=1),t.viewer.photoPosY>w.maxY?S=-1:t.viewer.photoPosY<w.minY&&(S=1),(g!==0||S!==0)&&re(g,S),t.viewer.scale=!0,t.viewer.hideUi=!0,e.onGestureEnd()}function we(){var J;s=!1;let a=m,h=p,w=Date.now(),g=n-w,S=h.x-a.x,H=h.y-a.y,G=S===0&&H===0;if(!q()&&G){e.onTap(x);return}if(Math.abs(g)<=500&&G){e.onTap(x);return}n=w;let ge=(J=I(t))!=null?J:[];if(c==="horizontal"){let Y="stay",Q=Math.max(w-f,1),U=Math.abs(S)>=ut&&Math.abs(S)/Q>=t.options.swipeVelocity;(S>=t.options.swipeOffset||U&&S>0)&&t.viewer.currentIndex!==0?Y="prev":(S<=-t.options.swipeOffset||U&&S<0)&&t.viewer.currentIndex!==ge.length-1&&(Y="next"),e.onSwipeEnd(Y)}else{let Y="stay";t.options.swipeBottomToClose&&H>=t.options.swipeOffset?Y="close-bottom":t.options.swipeTopToClose&&H<=-t.options.swipeOffset&&(Y="close-top"),e.onSwipeEnd(Y)}}function je(){b=!1;let a=C,h=M;if(a.x===h.x&&a.y===h.y){e.onPhotoDragEnd("zoom-out");return}let w=T(t);if(!w){e.onPhotoDragEnd(null);return}let g=j(w),S=t.options.swipeOffset*t.viewer.scaleSize,H=0,G=0;if(t.viewer.photoPosX>g.maxX?H=-1:t.viewer.photoPosX<g.minX&&(H=1),t.viewer.photoPosY>g.maxY?G=-1:t.viewer.photoPosY<g.minY&&(G=1),t.viewer.photoPosX-g.maxX>S&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(g.minX-t.viewer.photoPosX>S&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}H===0&&G===0?(u=N/5,X=W/5):re(H,G),e.onPhotoDragEnd(null)}function Ce(a){if(o.delete(a.pointerId),z){o.size<2?(F(),o.clear()):se();return}if(b){je();return}s&&we()}function Ke(...a){for(let h of a)h.addEventListener("pointerdown",v,{signal:i}),h.addEventListener("pointermove",R,{signal:i}),h.addEventListener("pointerup",Ce,{signal:i}),h.addEventListener("pointercancel",Ce,{signal:i})}function Qe(){clearInterval(pe),V!==null&&(cancelAnimationFrame(V),V=null)}return{attach:Ke,detach:Qe}}function ce(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function Le(){let t=document.createElement("button");return t.type="button",t}function dt(t){return t.replace(/"/g,'\\"')}function _e({id:t,options:e},i,{signal:o}){let{classNames:n,message:s}=e,r=document.createElement("div");r.setAttribute("data-id",t);let m=document.createElement("dialog");m.className=n.smartPhoto,m.setAttribute("aria-labelledby",`smartphoto-${t}-title`),m.style.display="none",m.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=n.smartPhotoBody;let c=document.createElement("div");c.className=n.smartPhotoInner;let f=document.createElement("div");f.className=n.smartPhotoHeader;let x=document.createElement("span");x.className=n.smartPhotoCount;let b=document.createElement("h1");b.id=`smartphoto-${t}-title`,b.className=n.smartPhotoCaption,b.setAttribute("tabindex","-1");let M=document.createElement("button");M.className=n.smartPhotoDismiss,M.appendChild(ce(s.closeDialog)),M.addEventListener("click",()=>i.onDismiss(),{signal:o}),f.append(x,b,M);let C=document.createElement("div");C.className=n.smartPhotoContent,C.addEventListener("click",d=>{d.target===C&&i.onBackdropClick()},{signal:o});let N=document.createElement("ul");N.className=n.smartPhotoList,N.setAttribute("role","region"),N.setAttribute("aria-roledescription","carousel"),N.setAttribute("aria-label",s.carouselLabel),N.setAttribute("aria-live","polite"),N.setAttribute("aria-atomic","false"),c.append(f,C,N);let W=null,z=null,B=null;if(e.arrows){W=document.createElement("ul"),W.className=n.smartPhotoArrows,z=document.createElement("li"),z.className=n.smartPhotoArrowLeft;let d=Le();d.appendChild(ce(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),z.appendChild(d),B=document.createElement("li"),B.className=n.smartPhotoArrowRight;let l=Le();l.appendChild(ce(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),B.appendChild(l),W.append(z,B),c.appendChild(W)}let D=null,V=null;e.nav&&(D=document.createElement("nav"),D.className=n.smartPhotoNav,D.setAttribute("aria-label","Choose slide to display"),V=document.createElement("ul"),D.appendChild(V),c.appendChild(D)),p.appendChild(c),m.appendChild(p),r.appendChild(m);let u={dialog:m,count:x,caption:b,dismiss:M,content:C,list:N,arrows:W,arrowLeft:z,arrowRight:B,nav:D,navList:V,slides:new Map,imgClone:null};function X(){let d=document.createElement("div");d.className=n.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=n.smartPhotoLoader,d.appendChild(l),d}function q(d){var y,P;let l=document.createElement("div");l.className=n.smartPhotoImgWrap;let v=document.createElement("img");return v.className=n.smartPhotoImg,v.src=(y=d.src)!=null?y:"",v.alt=(P=d.alt)!=null?P:"",v.addEventListener("dragstart",E=>E.preventDefault(),{signal:o}),l.appendChild(v),{imgWrap:l,img:v}}function j(d,l){var v;u.list.replaceChildren(),(v=u.navList)==null||v.replaceChildren(),u.slides=new Map,d.forEach(y=>{var A,k;let P=document.createElement("li");P.setAttribute("role","group"),P.setAttribute("aria-roledescription","slide"),P.setAttribute("aria-label",`${y.index+1} of ${d.length}`);let E={li:P,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(y.processed){let{imgWrap:R,img:F}=q(y);P.appendChild(R),E.imgWrap=R,E.img=F}else{let R=X();P.appendChild(R),E.loaderWrap=R}if(u.list.appendChild(P),u.slides.set(y,E),u.navList){let R=document.createElement("li"),F=Le();F.style.backgroundImage=`url("${dt((A=y.thumb)!=null?A:"")}")`;let we=y.index;F.addEventListener("click",()=>i.onNavigate(we),{signal:o}),F.appendChild(ce(`go to ${(k=y.caption)!=null?k:""}`)),R.appendChild(F),u.navList.appendChild(R),E.navLink=F}}),ne(l)}function oe(d,l){var P;if(l.imgWrap||!d.processed)return l;let{imgWrap:v,img:y}=q(d);return(P=l.loaderWrap)==null||P.replaceWith(v),l.loaderWrap=null,l.imgWrap=v,l.img=y,l}function $(d){d&&document.activeElement&&d.contains(document.activeElement)&&u.caption.focus()}function ne(d,l){let{viewer:v}=d;u.count.textContent=`${v.currentIndex+1}/${v.total}`,u.slides.forEach((y,P)=>{var k;let E=oe(P,y),A=P.index===v.currentIndex;E.li.style.transition=l!=null&&l.immediate?"none":"",E.li.style.transform=`translate(${P.translateX}px,${P.translateY}px)`,E.li.classList.toggle("current",A),A?E.li.removeAttribute("aria-hidden"):E.li.setAttribute("aria-hidden","true"),A&&(u.caption.textContent=(k=P.caption)!=null?k:""),E.imgWrap&&E.img&&(E.imgWrap.style.transform=`translate(${P.x}px,${P.y}px) scale(${P.scale})`,E.img.style.width=`${P.width}px`,A||(E.img.style.transform="translate(0px,0px) scale(1)"),E.img.classList.toggle("active",v.appear),E.img.classList.toggle(n.smartPhotoImgOnMove,v.scale),E.img.classList.toggle(n.smartPhotoImgElasticMove,v.elastic)),E.navLink&&(E.navLink.classList.toggle("current",A),A?E.navLink.setAttribute("aria-current","true"):E.navLink.removeAttribute("aria-current"))}),u.arrowLeft&&(v.showPrevArrow?u.arrowLeft.removeAttribute("aria-hidden"):($(u.arrowLeft),u.arrowLeft.setAttribute("aria-hidden","true"))),u.arrowRight&&(v.showNextArrow?u.arrowRight.removeAttribute("aria-hidden"):($(u.arrowRight),u.arrowRight.setAttribute("aria-hidden","true"))),u.arrows&&(v.hideUi&&$(u.arrows),u.arrows.setAttribute("aria-hidden",v.hideUi?"true":"false")),u.nav&&(v.hideUi&&$(u.nav),u.nav.setAttribute("aria-hidden",v.hideUi?"true":"false"))}function de(d){for(let[l,v]of u.slides)if(l.index===d.viewer.currentIndex)return v;return null}function me(d){let{viewer:l}=d,v=de(d),y=v==null?void 0:v.img;y&&(y.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,y.classList.toggle(n.smartPhotoImgOnMove,l.scale),y.classList.toggle(n.smartPhotoImgElasticMove,l.elastic)),u.nav&&(l.hideUi&&$(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.arrows&&(l.hideUi&&$(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function re(d){let{viewer:l}=d;u.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,u.list.classList.toggle(n.smartPhotoListOnMove,l.onMove)}function pe(d){for(let[l,v]of u.slides){if(l.index!==d.viewer.currentIndex)continue;let{img:y,imgWrap:P}=v;if(!y||!P||!l.width||!l.scale||l.scale>=1)return;let E=y.getBoundingClientRect();y.style.width=`${l.width*l.scale}px`,P.style.transform=`translate(${l.x}px,${l.y}px) scale(1)`;let A=y.getBoundingClientRect();P.style.transform=`translate(${l.x+E.left-A.left}px,${l.y+E.top-A.top}px) scale(1)`;return}}function K(){for(let[d,l]of u.slides){let{img:v,imgWrap:y}=l;v&&y&&(y.style.transform=`translate(${d.x}px,${d.y}px) scale(${d.scale})`,v.style.width=`${d.width}px`)}}function fe(d){let l=document.createElement("img");l.className=n.smartPhotoImgClone,l.src=d.img,l.style.width=`${d.width}px`,l.style.height=`${d.height}px`,l.style.transform=`translate(${d.left}px,${d.top}px) scale(1)`,p.appendChild(l),u.imgClone=l}function se(){var d;(d=u.imgClone)==null||d.remove(),u.imgClone=null}function ve(){r.remove()}return{root:r,refs:u,render:ne,syncSlides:j,updatePhotoTransform:me,applyViewTransitionLayout:pe,resetViewTransitionLayout:K,updateListTransform:re,showAppearEffect:fe,removeAppearEffect:se,destroy:ve}}var L=le,O=he;function mt(t){return t.length>0&&t[0]instanceof Element}function pt(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function qe(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var ie=class{constructor(e,i){this.id=pt();this.abortController=new AbortController;this.isSmartPhoneFlag=ae();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.isViewTransitionActive=!1;this.pendingViewTransitionResync=!1;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.rootSelector=null;this.itemsByElement=new Map;this.handleDocumentClick=e=>{if(!(e.target instanceof Element))return;let i=e;if(i.__smartphotoClaimed)return;let o=this.findRegisteredAncestor(e.target);if(!o&&this.rootSelector&&(o=e.target.closest(this.rootSelector)),!o)return;if(e.preventDefault(),i.__smartphotoClaimed=!0,!this.itemsByElement.has(o)&&this.rootSelector){let s=ee(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let n=this.itemsByElement.get(o);n&&this.openPhoto(n,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${O()}px`)};this.handleVisualViewportResize=()=>{if(this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!I(this.state))){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit(!0)}};this.handleResize=()=>{if(!(!this.state.viewer.isOpen||!I(this.state))){if(this.updateViewportHeight(),this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit(!0)}};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!this.state.viewer.isOpen||!I(this.state))return;if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit(!0);let e=L(),i=O(),o=500,n=s=>{this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(e!==L()||i!==O()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit(!0)):s<=o&&n(s+25))},25)};n(0)};this.rootSelector=typeof e=="string"?e:null,this.state=Re(i!=null?i:{}),this.view=_e({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Ue({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),document.addEventListener("click",this.handleDocumentClick,{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&this.openPhoto(o,o.element),this.updateViewportHeight(),this.applyAutoIconContrast(),window.visualViewport?window.visualViewport.addEventListener("resize",this.handleVisualViewportResize,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,n=s=>i.call(o,s);o.addEventListener(e,n,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.itemsByElement.clear(),this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){var s,r;let i=Number.parseInt(String(e),10),o=Number.isNaN(i)?0:i,n=(r=(s=I(this.state))==null?void 0:s.length)!=null?r:0;o<0||o>=n||(this.state.viewer.currentIndex=o,this.slideList())}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=qe();location.hash&&this.setHash(""),window.scroll(i.x,i.y),this.syncDialog(),(o=this.lastTriggerElement)!=null&&o.isConnected&&this.lastTriggerElement.focus(),this.lastTriggerElement=null,this.doHideEffect(e).then(()=>{this.view.render(this.state),this.isFiringPublicCloseEvent=!0,this.fireEvent("close"),this.isFiringPublicCloseEvent=!1})}zoomPhoto(){let e=T(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=_(e,L(),O(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin"))},this.state.options.animationSpeed)))}canZoomCurrentPhoto(){let e=T(this.state);return!!e&&_(e,L(),O(),this.isSmartPhoneFlag)>1}zoomOutPhoto(){let e=T(this.state),i=this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag&&e?_(e,L(),O(),!0):1;this.state.viewer.scaleSize=i,this.state.viewer.hideUi=i>1,this.state.viewer.scale=i>1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var p,c,f;let o=(p=i.group)!=null?p:this.state.viewer.currentGroup;if(o===null)return;let n=this.state.groups.get(o);if(!(n!=null&&n.length))return;let s=typeof e=="number"?n[e]:n.find(x=>x.id===e);if(!s)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,m=(f=(c=i.trigger)!=null?c:s.element)!=null?f:r;this.openPhoto(s,m)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof HTMLElement?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!mt(e)){e.forEach(o=>{this.addSlideItem(o)});return}Array.from(typeof e=="string"?document.querySelectorAll(e):e).forEach(o=>{this.addElementItem(o)})}addElementItem(e){var s,r;let i=ee(e),o=(r=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?r:0,n=be(e,this.state.options,o,L());return Se(this.state,n),this.loadAllFired.delete(i),this.itemsByElement.set(e,n),n}addSlideItem(e){var s,r;let i=Pe(e),o=(r=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?r:0,n=Ye(e,o,L());return Se(this.state,n),this.loadAllFired.delete(i),n}findRegisteredAncestor(e){let i=e;for(;i;){if(this.itemsByElement.has(i))return i;i=i.parentElement}return null}resyncGroupFromDom(e){var p;if(!this.rootSelector)return!1;let i=Array.from(document.querySelectorAll(this.rootSelector)).filter(c=>ee(c)===e),o=new Set(i),n=(p=this.state.groups.get(e))!=null?p:[],s=new Map;n.forEach(c=>{c.element&&s.set(c.element,c)});let r=i.length!==n.length,m=i.map((c,f)=>{let x=s.get(c);if(x)return x.index!==f&&(r=!0,x.index=f),x;r=!0;let b=be(c,this.state.options,f,L());return this.itemsByElement.set(c,b),b});return n.forEach(c=>{c.element&&!o.has(c.element)&&this.itemsByElement.delete(c.element)}),Ie(m,L()),this.state.groups.set(e,m),r&&this.loadAllFired.delete(e),r}syncCurrentGroupView(){let e=I(this.state);e&&(this.view.syncSlides(e,this.state),this.syncedGroupId=this.state.viewer.currentGroup)}setHash(e){var o;if(!((o=window.history)!=null&&o.pushState)||!this.state.options.useHistoryApi)return;let i=`${location.pathname}${location.search}`;window.history.replaceState(null,"",e?`${i}#${e}`:i)}setHashByCurrentIndex(){let e=qe();this.setHash(We(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?$e(this.state,Ne(e)):null}setPosByCurrentIndex(){let e=T(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=I(this.state);e&&(Ge(e,L(),O(),this.state.options.headerHeight,this.state.options.footerHeight),this.syncFillScale())}resetTranslateCurrent(){Ie(I(this.state),L())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}currentLiElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.li;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;e.style.transition=this.state.options.showAnimation===!1?"none":"",this.state.viewer.isOpen&&!e.open?(e.style.removeProperty("display"),e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&(e.close(),e.style.display="none")}commit(e=!1){this.view.render(this.state,{immediate:e}),this.view.updatePhotoTransform(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=I(this.state);this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),xe(this.state)}syncFillScale(){if(this.state.options.resizeStyle!=="fill"||!this.isSmartPhoneFlag)return;let e=T(this.state);e&&(this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=_(e,L(),O(),this.isSmartPhoneFlag))}supportsViewTransition(){return this.state.options.useViewTransitionApi&&typeof document.startViewTransition=="function"&&!Me()}openPhotoWithViewTransition(e){var r,m;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(r=e==null?void 0:e.querySelector("img"))!=null?r:null;o&&(o.style.viewTransitionName=i);let n=()=>{this.isViewTransitionActive=!1,o&&(o.style.viewTransitionName="");let p=this.currentImgElement();if(p&&(p.style.viewTransitionName=""),!this.state.viewer.isOpen){this.pendingViewTransitionResync=!1;return}if(this.pendingViewTransitionResync&&I(this.state)){this.pendingViewTransitionResync=!1,this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit(!0);return}this.pendingViewTransitionResync=!1,this.view.resetViewTransitionLayout()},s=(m=document.startViewTransition)==null?void 0:m.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i,this.view.applyViewTransitionLayout(this.state)});s&&(this.isViewTransitionActive=!0,s.ready.catch(()=>{n()}),s.finished.then(n,n))}addAppearEffect(e,i){var C;let o=(C=e==null?void 0:e.querySelector("img"))!=null?C:null;if(!o){this.state.viewer.appear=!0;return}let n=Be(o),s=o.offsetWidth,r=o.offsetHeight,m=L(),p=O(),c=p-this.state.options.headerHeight-this.state.options.footerHeight,f=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>r?f=p/r:f=m/s:(s>=r?i.height<c?f=i.width/s:f=c/r:i.height<c?f=i.height/r:f=c/r,s*f>m&&(f=m/s));let x=(f-1)/2*s+(m-s*f)/2,b=(f-1)/2*r+(p-r*f)/2,M=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:r,top:n.top,left:n.left,once:!0,img:M||i.src||"",afterX:x,afterY:b,scale:f}}runAppearEffect(e){this.view.showAppearEffect(e);let i=this.view.refs.imgClone;return new Promise(o=>{let n=()=>{i.removeEventListener("transitionend",n,!0),o()};i.addEventListener("transitionend",n,!0),this.scheduleTimeout(()=>{i.style.transform=`translate(${e.afterX}px, ${e.afterY}px) scale(${e.scale})`},10)})}doOpen(e,i){if(this.state.options.showAnimation!==!1&&this.supportsViewTransition())this.openPhotoWithViewTransition(e);else if(this.state.options.showAnimation===!1)this.initPhoto(),this.state.viewer.appear=!0,this.commit();else{this.initPhoto(),this.addAppearEffect(e,i),this.commit();let o=this.state.viewer.appearEffect;o&&this.runAppearEffect(o).then(()=>{this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.appear=!0,this.commit()})}this.fireEvent("open"),this.resyncSizeAfterOpen()}resyncSizeAfterOpen(){let e=L(),i=O();requestAnimationFrame(()=>{if(this.state.viewer.isOpen&&!(L()===e&&O()===i)){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit(!0)}})}openPhoto(e,i){let o=this.resyncGroupFromDom(e.groupId);this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,(this.syncedGroupId!==e.groupId||o)&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{if(this.state.options.showAnimation===!1){i();return}let o=this.view.refs.dialog,n=T(this.state),s=n?this.currentLiElement():null,r=O(),m=this.currentImgElement(),p=null;if(m){let f=getComputedStyle(m).transform;f&&f!=="none"&&(m.style.transform=f,p=m.style.transform)}if(s&&n){let f=e==="top"?-r:r;s.style.transform=`translate(${n.translateX}px,${n.translateY+f}px)`}let c=f=>{this.finishHideEffect===c&&(f&&f.target!==o||(this.finishHideEffect=null,o.removeEventListener("transitionend",c,!0),m&&p&&m.style.transform===p&&(m.style.transform=""),i()))};this.finishHideEffect=c,o.addEventListener("transitionend",c,!0),this.scheduleTimeout(c,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var n;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(n=e.src)!=null?n:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=I(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,n=[];for(let s=i-o;s<i+o;s++){let r=e[s];r&&!r.loaded&&n.push(this.loadItem(r))}n.length&&Promise.all(n).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.updateViewportHeight(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=T(this.state);this.state.viewer.onMove=!1,xe(this.state),this.state.viewer.isOpen&&this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(n=>n!==o),e()},i);return this.timeouts.push(o),o}applyAutoIconContrast(){let e=this.view.refs.dialog,i=getComputedStyle(e);if(i.getPropertyValue("--smartphoto-icon-color").trim())return;let o=i.getPropertyValue("--smartphoto-backdrop-color").trim();o&&e.style.setProperty("--smartphoto-icon-color",De(o))}fireEvent(e){Oe(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:e=>{let i=this.currentImgElement();!!i&&e instanceof Node&&i.contains(e)&&this.canZoomCurrentPhoto()?this.zoomPhoto():this.hidePhoto()},onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},onPinchClose:()=>this.hidePhoto(),onPhotoDragMove:()=>this.view.updatePhotoTransform(this.state),onPhotoDragEnd:e=>{if(e==="zoom-out"){this.zoomOutPhoto();return}if(e==="prev"){this.gotoSlide(this.state.viewer.prev);return}if(e==="next"){this.gotoSlide(this.state.viewer.next);return}this.view.updatePhotoTransform(this.state)}}}};var ft=ie;return rt(vt);})();
6
+ "use strict";var SmartPhoto=(()=>{var ye=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var it=Object.prototype.hasOwnProperty;var ot=(t,e)=>{for(var i in e)ye(t,i,{get:e[i],enumerable:!0})},nt=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of tt(e))!it.call(t,n)&&n!==i&&ye(t,n,{get:()=>e[n],enumerable:!(o=et(e,n))||o.enumerable});return t};var rt=t=>nt(ye({},"__esModule",{value:!0}),t);var vt={};ot(vt,{default:()=>ft});var ae=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},Me=()=>typeof window.webkitConvertPointFromNodeToPage=="function";function Ve(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let n=e[o];if(n){for(let s in n)if(Object.hasOwn(n,s)){let r=n[s];r&&typeof r=="object"?t[s]=Ve((i=t[s])!=null?i:{},r):t[s]=r}}}return t}var ze=Ve,Oe=(t,e,i)=>{let o;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,i)),t.dispatchEvent(o)},Ne=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),n=o[0],s=o.length>1?o.slice(1).join("="):n;e[n]=decodeURIComponent(s)}return e},le=()=>document.documentElement.clientWidth,he=()=>{let t=window.visualViewport;if(t){let e=document.documentElement.clientWidth;return t.width>0&&e>0?t.height*(e/t.width):t.height*t.scale}return document.documentElement.clientHeight},Be=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var He=t=>{let e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/);return e?[Number(e[1]),Number(e[2]),Number(e[3])]:null},st=.179,at=([t,e,i])=>{let[o,n,s]=[t,e,i].map(r=>{let m=r/255;return m<=.03928?m/12.92:((m+.055)/1.055)**2.4});return .2126*o+.7152*n+.0722*s},De=t=>{let e=t.trim(),i=He(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=He(getComputedStyle(o).color),document.body.removeChild(o)}return i&&at(i)>st?"#000":"#fff"};var lt={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,useViewTransitionApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,pinchToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:300};function Xe(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Xe(i)}),Object.freeze(t)}function Re(t){return{options:Xe(ze({},lt,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function ee(t){return t.getAttribute("data-group")||"nogroup"}function Pe(t){return t.group||"nogroup"}function be(t,e,i,o){let n=ee(t),s=t.getAttribute("href"),r=t.querySelector("img"),m=s;r&&(r.getAttribute(e.lazyAttribute)?m=r.getAttribute(e.lazyAttribute):r.currentSrc?m=r.currentSrc:m=r.src);let p="";r!=null&&r.getAttribute("alt")?p=r.getAttribute("alt"):t.getAttribute("data-caption")?p=t.getAttribute("data-caption"):p=s!=null?s:"";let c=t.getAttribute("data-id");return{src:s,thumb:m,caption:t.getAttribute("data-caption"),alt:p,groupId:n,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:c||i,loaded:!1,processed:!1,element:t}}function Ye(t,e,i){var c,f,x,b,M;let o=Pe(t),n=t.src,s=(c=t.thumb)!=null?c:n,r=(f=t.caption)!=null?f:null,m=(b=(x=t.alt)!=null?x:r)!=null?b:n,p=typeof t.width=="number"&&typeof t.height=="number";return{src:n,thumb:s,caption:r,alt:m,groupId:o,translateX:i*e,translateY:0,index:e,width:p?t.width:50,height:p?t.height:50,scale:1,x:0,y:0,id:(M=t.id)!=null?M:e,loaded:p,processed:!1,element:null}}function Se(t,e){t.groups.has(e.groupId)||t.groups.set(e.groupId,[]),t.groups.get(e.groupId).push(e),t.viewer.currentGroup=e.groupId}function I(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function T(t){var i;let e=I(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function xe(t){let e=I(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,n=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),n!==-1&&(t.viewer.prev=n,t.viewer.showPrevArrow=!0)}function Ie(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function ue(t,e){let i=10**e;return Math.round(t*i)/i}function _(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function We(t,e,i,o){let n=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,r,m,p,c;return i>n?(p=(i-n)/2,r=-1*p):(p=(n-i)/2,r=-1*p),o>s?(c=(o-s)/2,m=-1*c):(c=(s-o)/2,m=-1*c),{minX:ue(r,6)/t.scale,minY:ue(m,6)/t.scale,maxX:ue(p,6)/t.scale,maxY:ue(c,6)/t.scale}}var ht=24;function Fe(t,e,i,o,n){let s=i-(o+n)-ht*2;t.forEach(r=>{r.loaded&&(r.processed=!0,r.scale=s/r.height,r.height<s&&(r.scale=1),r.x=(r.scale-1)/2*r.width+(e-r.width*r.scale)/2,r.y=(r.scale-1)/2*r.height+(i-r.height*r.scale)/2,r.width*r.scale>e&&(r.scale=e/r.width,r.x=(r.scale-1)/2*r.width))})}function Ge(t){let e=T(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function $e(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(n=>{e.group===n.groupId&&e.photo===n.id&&(i=n)})}),i}function te(t,e){let i=10**e;return Math.round(t*i)/i}function Z(t){return{x:t.clientX,y:t.clientY}}function ke(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var ut=10;function ct(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Te(){return{width:le(),height:he()}}function Ue({state:t,callbacks:e},{signal:i}){let o=new Map,n=Date.now(),s=!1,r=!1,m=null,p=null,c=null,f=0,x=null,b=!1,M=null,C=null,N=0,G=0,z=!1,B=0,D=1,V=null,u=0,X=0;function q(){return ae()}function j(a){let{width:h,height:w}=Te();return We(a,t.viewer,h,w)}function oe(a){let{width:h,height:w}=Te();return _(a,h,w,q())}function $(a){return t.options.resizeStyle==="fill"&&q()?oe(a):1}let ne=4;function de(a){return Math.max(ne,oe(a))}let me=.75;function re(a,h){let w=T(t),g=j(w);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=g.minX:a===-1&&(t.viewer.photoPosX=g.maxX),h===1?t.viewer.photoPosY=g.minY:h===-1&&(t.viewer.photoPosY=g.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let pe=setInterval(()=>{if(z||s||b||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=u,t.viewer.photoPosY+=X;let a=T(t);if(!a)return;let h=j(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,u*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,u*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,X*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,X*=-.2);let w=ct(u,X),g=w.force-t.options.registance;g<.5||(u=Math.cos(w.theta)*g,X=Math.sin(w.theta)*g,e.onPhotoDragMove())},t.options.forceInterval);function K(a,h){(a>5||a<-5)&&(u+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(X+=h*.05)}function fe(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||z||s||b||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?K(a.gamma,a.beta):h===90?K(a.beta,a.gamma):h===-90?K(-a.beta,-a.gamma):h===180&&K(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",fe,{signal:i});function se(){let a=Array.from(o.values());B=ke(a[0],a[1]),D=t.viewer.scaleSize}function ve(){z=!0,s=!1,b=!1,se(),u=0,X=0,t.viewer.scale=!0,t.viewer.hideUi=!0,e.onGestureStart()}function d(a){let h=Z(a);s=!0,r=!0,m=h,p=h,f=Date.now(),x=a.target}function l(a){b=!0;let h=Z(a);C=h,M=h}function v(a){var h,w;try{(w=(h=a.currentTarget).setPointerCapture)==null||w.call(h,a.pointerId)}catch(g){}if(o.set(a.pointerId,Z(a)),o.size>1){ve();return}if(t.viewer.scale){l(a);return}d(a)}function y(){V===null&&(V=requestAnimationFrame(()=>{V=null,e.onGestureMove()}))}function P(){V!==null&&(cancelAnimationFrame(V),V=null,e.onGestureMove())}function E(){let a=Array.from(o.values()),h=a[0],w=a[1],g=ke(h,w);if(B===0){B=g,D=t.viewer.scaleSize,y();return}let S=t.viewer.scaleSize;t.viewer.scaleSize=te(D*g/B,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2);let H=T(t);if(H&&t.viewer.scaleSize!==S){let{width:F,height:ge}=Te(),J=F/2,Y=t.options.headerHeight+(ge-t.options.headerHeight-t.options.footerHeight)/2,Q=H.scale,U={x:(h.x+w.x)/2,y:(h.y+w.y)/2},Ae=t.viewer.scaleSize/S,Ze=U.x-(J+t.viewer.photoPosX*Q),Je=U.y-(Y+t.viewer.photoPosY*Q);t.viewer.photoPosX=te((U.x-Ze*Ae-J)/Q,6),t.viewer.photoPosY=te((U.y-Je*Ae-Y)/Q,6)}y()}function A(a){let h=Z(a),w=h.x-p.x,g=h.y-m.y;r&&(e.onSwipeStart(),r=!1,c=Math.abs(w)>Math.abs(g)?"horizontal":"vertical"),c==="horizontal"?t.viewer.translateX+=w:t.viewer.translateY=g,p=h,e.onSwipeMove()}function k(a){let h=Z(a),w=h.x-C.x,g=h.y-C.y,S=te(t.viewer.scaleSize*w,6),H=te(t.viewer.scaleSize*g,6);t.viewer.photoPosX+=S,N=S,t.viewer.photoPosY+=H,G=H,C=h,e.onPhotoDragMove()}function R(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,Z(a)),z){E();return}if(b){k(a);return}A(a)}}function W(){z=!1,P();let a=T(t);if(!a)return;let h=$(a);if(t.viewer.scaleSize<=h){if(t.options.pinchToClose&&t.viewer.scaleSize<h*me){e.onPinchClose();return}t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scaleSize=h,t.viewer.scale=h>1,t.viewer.hideUi=h>1,e.onGestureEnd();return}t.viewer.scaleSize=Math.min(t.viewer.scaleSize,de(a));let w=j(a),g=0,S=0;t.viewer.photoPosX>w.maxX?g=-1:t.viewer.photoPosX<w.minX&&(g=1),t.viewer.photoPosY>w.maxY?S=-1:t.viewer.photoPosY<w.minY&&(S=1),(g!==0||S!==0)&&re(g,S),t.viewer.scale=!0,t.viewer.hideUi=!0,e.onGestureEnd()}function we(){var J;s=!1;let a=m,h=p,w=Date.now(),g=n-w,S=h.x-a.x,H=h.y-a.y,F=S===0&&H===0;if(!q()&&F){e.onTap(x);return}if(Math.abs(g)<=500&&F){e.onTap(x);return}n=w;let ge=(J=I(t))!=null?J:[];if(c==="horizontal"){let Y="stay",Q=Math.max(w-f,1),U=Math.abs(S)>=ut&&Math.abs(S)/Q>=t.options.swipeVelocity;(S>=t.options.swipeOffset||U&&S>0)&&t.viewer.currentIndex!==0?Y="prev":(S<=-t.options.swipeOffset||U&&S<0)&&t.viewer.currentIndex!==ge.length-1&&(Y="next"),e.onSwipeEnd(Y)}else{let Y="stay";t.options.swipeBottomToClose&&H>=t.options.swipeOffset?Y="close-bottom":t.options.swipeTopToClose&&H<=-t.options.swipeOffset&&(Y="close-top"),e.onSwipeEnd(Y)}}function je(){b=!1;let a=C,h=M;if(a.x===h.x&&a.y===h.y){e.onPhotoDragEnd("zoom-out");return}let w=T(t);if(!w){e.onPhotoDragEnd(null);return}let g=j(w),S=t.options.swipeOffset*t.viewer.scaleSize,H=0,F=0;if(t.viewer.photoPosX>g.maxX?H=-1:t.viewer.photoPosX<g.minX&&(H=1),t.viewer.photoPosY>g.maxY?F=-1:t.viewer.photoPosY<g.minY&&(F=1),t.viewer.photoPosX-g.maxX>S&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(g.minX-t.viewer.photoPosX>S&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}H===0&&F===0?(u=N/5,X=G/5):re(H,F),e.onPhotoDragEnd(null)}function Ce(a){if(o.delete(a.pointerId),z){o.size<2?(W(),o.clear()):se();return}if(b){je();return}s&&we()}function Ke(...a){for(let h of a)h.addEventListener("pointerdown",v,{signal:i}),h.addEventListener("pointermove",R,{signal:i}),h.addEventListener("pointerup",Ce,{signal:i}),h.addEventListener("pointercancel",Ce,{signal:i})}function Qe(){clearInterval(pe),V!==null&&(cancelAnimationFrame(V),V=null)}return{attach:Ke,detach:Qe}}function ce(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function Le(){let t=document.createElement("button");return t.type="button",t}function dt(t){return t.replace(/"/g,'\\"')}function _e({id:t,options:e},i,{signal:o}){let{classNames:n,message:s}=e,r=document.createElement("div");r.setAttribute("data-id",t);let m=document.createElement("dialog");m.className=n.smartPhoto,m.setAttribute("aria-labelledby",`smartphoto-${t}-title`),m.style.display="none",m.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=n.smartPhotoBody;let c=document.createElement("div");c.className=n.smartPhotoInner;let f=document.createElement("div");f.className=n.smartPhotoHeader;let x=document.createElement("span");x.className=n.smartPhotoCount;let b=document.createElement("h1");b.id=`smartphoto-${t}-title`,b.className=n.smartPhotoCaption,b.setAttribute("tabindex","-1");let M=document.createElement("button");M.className=n.smartPhotoDismiss,M.appendChild(ce(s.closeDialog)),M.addEventListener("click",()=>i.onDismiss(),{signal:o}),f.append(x,b,M);let C=document.createElement("div");C.className=n.smartPhotoContent,C.addEventListener("click",d=>{d.target===C&&i.onBackdropClick()},{signal:o});let N=document.createElement("ul");N.className=n.smartPhotoList,N.setAttribute("role","region"),N.setAttribute("aria-roledescription","carousel"),N.setAttribute("aria-label",s.carouselLabel),N.setAttribute("aria-live","polite"),N.setAttribute("aria-atomic","false"),c.append(f,C,N);let G=null,z=null,B=null;if(e.arrows){G=document.createElement("ul"),G.className=n.smartPhotoArrows,z=document.createElement("li"),z.className=n.smartPhotoArrowLeft;let d=Le();d.appendChild(ce(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),z.appendChild(d),B=document.createElement("li"),B.className=n.smartPhotoArrowRight;let l=Le();l.appendChild(ce(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),B.appendChild(l),G.append(z,B),c.appendChild(G)}let D=null,V=null;e.nav&&(D=document.createElement("nav"),D.className=n.smartPhotoNav,D.setAttribute("aria-label","Choose slide to display"),V=document.createElement("ul"),D.appendChild(V),c.appendChild(D)),p.appendChild(c),m.appendChild(p),r.appendChild(m);let u={dialog:m,count:x,caption:b,dismiss:M,content:C,list:N,arrows:G,arrowLeft:z,arrowRight:B,nav:D,navList:V,slides:new Map,imgClone:null};function X(){let d=document.createElement("div");d.className=n.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=n.smartPhotoLoader,d.appendChild(l),d}function q(d){var y,P;let l=document.createElement("div");l.className=n.smartPhotoImgWrap;let v=document.createElement("img");return v.className=n.smartPhotoImg,v.src=(y=d.src)!=null?y:"",v.alt=(P=d.alt)!=null?P:"",v.addEventListener("dragstart",E=>E.preventDefault(),{signal:o}),l.appendChild(v),{imgWrap:l,img:v}}function j(d,l){var v;u.list.replaceChildren(),(v=u.navList)==null||v.replaceChildren(),u.slides=new Map,d.forEach(y=>{var A,k;let P=document.createElement("li");P.setAttribute("role","group"),P.setAttribute("aria-roledescription","slide"),P.setAttribute("aria-label",`${y.index+1} of ${d.length}`);let E={li:P,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(y.processed){let{imgWrap:R,img:W}=q(y);P.appendChild(R),E.imgWrap=R,E.img=W}else{let R=X();P.appendChild(R),E.loaderWrap=R}if(u.list.appendChild(P),u.slides.set(y,E),u.navList){let R=document.createElement("li"),W=Le();W.style.backgroundImage=`url("${dt((A=y.thumb)!=null?A:"")}")`;let we=y.index;W.addEventListener("click",()=>i.onNavigate(we),{signal:o}),W.appendChild(ce(`go to ${(k=y.caption)!=null?k:""}`)),R.appendChild(W),u.navList.appendChild(R),E.navLink=W}}),ne(l)}function oe(d,l){var P;if(l.imgWrap||!d.processed)return l;let{imgWrap:v,img:y}=q(d);return(P=l.loaderWrap)==null||P.replaceWith(v),l.loaderWrap=null,l.imgWrap=v,l.img=y,l}function $(d){d&&document.activeElement&&d.contains(document.activeElement)&&u.caption.focus()}function ne(d,l){let{viewer:v}=d;u.count.textContent=`${v.currentIndex+1}/${v.total}`,u.slides.forEach((y,P)=>{var k;let E=oe(P,y),A=P.index===v.currentIndex;E.li.style.transition=l!=null&&l.immediate?"none":"",E.li.style.transform=`translate(${P.translateX}px,${P.translateY}px)`,E.li.classList.toggle("current",A),A?E.li.removeAttribute("aria-hidden"):E.li.setAttribute("aria-hidden","true"),A&&(u.caption.textContent=(k=P.caption)!=null?k:""),E.imgWrap&&E.img&&(E.imgWrap.style.transform=`translate(${P.x}px,${P.y}px) scale(${P.scale})`,E.img.style.width=`${P.width}px`,A||(E.img.style.transform="translate(0px,0px) scale(1)"),E.img.classList.toggle("active",v.appear),E.img.classList.toggle(n.smartPhotoImgOnMove,v.scale),E.img.classList.toggle(n.smartPhotoImgElasticMove,v.elastic)),E.navLink&&(E.navLink.classList.toggle("current",A),A?E.navLink.setAttribute("aria-current","true"):E.navLink.removeAttribute("aria-current"))}),u.arrowLeft&&(v.showPrevArrow?u.arrowLeft.removeAttribute("aria-hidden"):($(u.arrowLeft),u.arrowLeft.setAttribute("aria-hidden","true"))),u.arrowRight&&(v.showNextArrow?u.arrowRight.removeAttribute("aria-hidden"):($(u.arrowRight),u.arrowRight.setAttribute("aria-hidden","true"))),u.arrows&&(v.hideUi&&$(u.arrows),u.arrows.setAttribute("aria-hidden",v.hideUi?"true":"false")),u.nav&&(v.hideUi&&$(u.nav),u.nav.setAttribute("aria-hidden",v.hideUi?"true":"false"))}function de(d){for(let[l,v]of u.slides)if(l.index===d.viewer.currentIndex)return v;return null}function me(d){let{viewer:l}=d,v=de(d),y=v==null?void 0:v.img;y&&(y.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,y.classList.toggle(n.smartPhotoImgOnMove,l.scale),y.classList.toggle(n.smartPhotoImgElasticMove,l.elastic)),u.nav&&(l.hideUi&&$(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.arrows&&(l.hideUi&&$(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function re(d){let{viewer:l}=d;u.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,u.list.classList.toggle(n.smartPhotoListOnMove,l.onMove)}function pe(d){for(let[l,v]of u.slides){if(l.index!==d.viewer.currentIndex)continue;let{img:y,imgWrap:P}=v;if(!y||!P||!l.width||!l.scale||l.scale>=1)return;let E=y.getBoundingClientRect();y.style.width=`${l.width*l.scale}px`,P.style.transform=`translate(${l.x}px,${l.y}px) scale(1)`;let A=y.getBoundingClientRect();P.style.transform=`translate(${l.x+E.left-A.left}px,${l.y+E.top-A.top}px) scale(1)`;return}}function K(){for(let[d,l]of u.slides){let{img:v,imgWrap:y}=l;v&&y&&(y.style.transform=`translate(${d.x}px,${d.y}px) scale(${d.scale})`,v.style.width=`${d.width}px`)}}function fe(d){let l=document.createElement("img");l.className=n.smartPhotoImgClone,l.src=d.img,l.style.width=`${d.width}px`,l.style.height=`${d.height}px`,l.style.transform=`translate(${d.left}px,${d.top}px) scale(1)`,p.appendChild(l),u.imgClone=l}function se(){var d;(d=u.imgClone)==null||d.remove(),u.imgClone=null}function ve(){r.remove()}return{root:r,refs:u,render:ne,syncSlides:j,updatePhotoTransform:me,applyViewTransitionLayout:pe,resetViewTransitionLayout:K,updateListTransform:re,showAppearEffect:fe,removeAppearEffect:se,destroy:ve}}var L=le,O=he;function mt(t){return t.length>0&&t[0]instanceof Element}function pt(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function qe(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var ie=class{constructor(e,i){this.id=pt();this.abortController=new AbortController;this.isSmartPhoneFlag=ae();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.isViewTransitionActive=!1;this.pendingViewTransitionResync=!1;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.rootSelector=null;this.itemsByElement=new Map;this.handleDocumentClick=e=>{if(!(e.target instanceof Element))return;let i=e;if(i.__smartphotoClaimed)return;let o=this.findRegisteredAncestor(e.target);if(!o&&this.rootSelector&&(o=e.target.closest(this.rootSelector)),!o)return;if(e.preventDefault(),i.__smartphotoClaimed=!0,!this.itemsByElement.has(o)&&this.rootSelector){let s=ee(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let n=this.itemsByElement.get(o);n&&this.openPhoto(n,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${O()}px`)};this.handleVisualViewportResize=()=>{if(this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!I(this.state))){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit(!0)}};this.handleResize=()=>{if(!(!this.state.viewer.isOpen||!I(this.state))){if(this.updateViewportHeight(),this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit(!0)}};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!this.state.viewer.isOpen||!I(this.state))return;if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit(!0);let e=L(),i=O(),o=500,n=s=>{this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(e!==L()||i!==O()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit(!0)):s<=o&&n(s+25))},25)};n(0)};this.rootSelector=typeof e=="string"?e:null,this.state=Re(i!=null?i:{}),this.view=_e({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Ue({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),document.addEventListener("click",this.handleDocumentClick,{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&this.openPhoto(o,o.element),this.updateViewportHeight(),this.applyAutoIconContrast(),window.visualViewport?window.visualViewport.addEventListener("resize",this.handleVisualViewportResize,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,n=s=>i.call(o,s);o.addEventListener(e,n,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.itemsByElement.clear(),this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){var s,r;let i=Number.parseInt(String(e),10),o=Number.isNaN(i)?0:i,n=(r=(s=I(this.state))==null?void 0:s.length)!=null?r:0;o<0||o>=n||(this.state.viewer.currentIndex=o,this.slideList())}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=qe();location.hash&&this.setHash(""),window.scroll(i.x,i.y),this.syncDialog(),(o=this.lastTriggerElement)!=null&&o.isConnected&&this.lastTriggerElement.focus(),this.lastTriggerElement=null,this.doHideEffect(e).then(()=>{this.view.render(this.state),this.isFiringPublicCloseEvent=!0,this.fireEvent("close"),this.isFiringPublicCloseEvent=!1})}zoomPhoto(){let e=T(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=_(e,L(),O(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin"))},this.state.options.animationSpeed)))}canZoomCurrentPhoto(){let e=T(this.state);return!!e&&_(e,L(),O(),this.isSmartPhoneFlag)>1}zoomOutPhoto(){let e=T(this.state),i=this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag&&e?_(e,L(),O(),!0):1;this.state.viewer.scaleSize=i,this.state.viewer.hideUi=i>1,this.state.viewer.scale=i>1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var p,c,f;let o=(p=i.group)!=null?p:this.state.viewer.currentGroup;if(o===null)return;let n=this.state.groups.get(o);if(!(n!=null&&n.length))return;let s=typeof e=="number"?n[e]:n.find(x=>x.id===e);if(!s)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,m=(f=(c=i.trigger)!=null?c:s.element)!=null?f:r;this.openPhoto(s,m)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof HTMLElement?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!mt(e)){e.forEach(o=>{this.addSlideItem(o)});return}Array.from(typeof e=="string"?document.querySelectorAll(e):e).forEach(o=>{this.addElementItem(o)})}addElementItem(e){var s,r;let i=ee(e),o=(r=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?r:0,n=be(e,this.state.options,o,L());return Se(this.state,n),this.loadAllFired.delete(i),this.itemsByElement.set(e,n),n}addSlideItem(e){var s,r;let i=Pe(e),o=(r=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?r:0,n=Ye(e,o,L());return Se(this.state,n),this.loadAllFired.delete(i),n}findRegisteredAncestor(e){let i=e;for(;i;){if(this.itemsByElement.has(i))return i;i=i.parentElement}return null}resyncGroupFromDom(e){var p;if(!this.rootSelector)return!1;let i=Array.from(document.querySelectorAll(this.rootSelector)).filter(c=>ee(c)===e),o=new Set(i),n=(p=this.state.groups.get(e))!=null?p:[],s=new Map;n.forEach(c=>{c.element&&s.set(c.element,c)});let r=i.length!==n.length,m=i.map((c,f)=>{let x=s.get(c);if(x)return x.index!==f&&(r=!0,x.index=f),x;r=!0;let b=be(c,this.state.options,f,L());return this.itemsByElement.set(c,b),b});return n.forEach(c=>{c.element&&!o.has(c.element)&&this.itemsByElement.delete(c.element)}),Ie(m,L()),this.state.groups.set(e,m),r&&this.loadAllFired.delete(e),r}syncCurrentGroupView(){let e=I(this.state);e&&(this.view.syncSlides(e,this.state),this.syncedGroupId=this.state.viewer.currentGroup)}setHash(e){var o;if(!((o=window.history)!=null&&o.pushState)||!this.state.options.useHistoryApi)return;let i=`${location.pathname}${location.search}`;window.history.replaceState(null,"",e?`${i}#${e}`:i)}setHashByCurrentIndex(){let e=qe();this.setHash(Ge(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?$e(this.state,Ne(e)):null}setPosByCurrentIndex(){let e=T(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=I(this.state);e&&(Fe(e,L(),O(),this.state.options.headerHeight,this.state.options.footerHeight),this.syncFillScale())}resetTranslateCurrent(){Ie(I(this.state),L())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}currentLiElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.li;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;e.style.transition=this.state.options.showAnimation===!1?"none":"",this.state.viewer.isOpen&&!e.open?(e.style.removeProperty("display"),e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&(e.close(),e.style.display="none")}commit(e=!1){this.view.render(this.state,{immediate:e}),this.view.updatePhotoTransform(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=I(this.state);this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),xe(this.state)}syncFillScale(){if(this.state.options.resizeStyle!=="fill"||!this.isSmartPhoneFlag)return;let e=T(this.state);e&&(this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=_(e,L(),O(),this.isSmartPhoneFlag))}supportsViewTransition(){return this.state.options.useViewTransitionApi&&typeof document.startViewTransition=="function"&&!Me()}openPhotoWithViewTransition(e){var r,m;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(r=e==null?void 0:e.querySelector("img"))!=null?r:null;o&&(o.style.viewTransitionName=i);let n=()=>{this.isViewTransitionActive=!1,o&&(o.style.viewTransitionName="");let p=this.currentImgElement();if(p&&(p.style.viewTransitionName=""),!this.state.viewer.isOpen){this.pendingViewTransitionResync=!1;return}if(this.pendingViewTransitionResync&&I(this.state)){this.pendingViewTransitionResync=!1,this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit(!0);return}this.pendingViewTransitionResync=!1,this.view.resetViewTransitionLayout()},s=(m=document.startViewTransition)==null?void 0:m.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i,this.view.applyViewTransitionLayout(this.state)});s&&(this.isViewTransitionActive=!0,s.ready.catch(()=>{n()}),s.finished.then(n,n))}addAppearEffect(e,i){var C;let o=(C=e==null?void 0:e.querySelector("img"))!=null?C:null;if(!o){this.state.viewer.appear=!0;return}let n=Be(o),s=o.offsetWidth,r=o.offsetHeight,m=L(),p=O(),c=p-this.state.options.headerHeight-this.state.options.footerHeight,f=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>r?f=p/r:f=m/s:(s>=r?i.height<c?f=i.width/s:f=c/r:i.height<c?f=i.height/r:f=c/r,s*f>m&&(f=m/s));let x=(f-1)/2*s+(m-s*f)/2,b=(f-1)/2*r+(p-r*f)/2,M=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:r,top:n.top,left:n.left,once:!0,img:M||i.src||"",afterX:x,afterY:b,scale:f}}runAppearEffect(e){this.view.showAppearEffect(e);let i=this.view.refs.imgClone;return new Promise(o=>{let n=()=>{i.removeEventListener("transitionend",n,!0),o()};i.addEventListener("transitionend",n,!0),this.scheduleTimeout(()=>{i.style.transform=`translate(${e.afterX}px, ${e.afterY}px) scale(${e.scale})`},10)})}doOpen(e,i){if(this.state.options.showAnimation!==!1&&this.supportsViewTransition())this.openPhotoWithViewTransition(e);else if(this.state.options.showAnimation===!1)this.initPhoto(),this.state.viewer.appear=!0,this.commit();else{this.initPhoto(),this.addAppearEffect(e,i),this.commit();let o=this.state.viewer.appearEffect;o&&this.runAppearEffect(o).then(()=>{this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.appear=!0,this.commit()})}this.fireEvent("open"),this.resyncSizeAfterOpen()}resyncSizeAfterOpen(){let e=L(),i=O();requestAnimationFrame(()=>{if(this.state.viewer.isOpen&&!(L()===e&&O()===i)){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit(!0)}})}openPhoto(e,i){let o=this.resyncGroupFromDom(e.groupId);this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,(this.syncedGroupId!==e.groupId||o)&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{if(this.state.options.showAnimation===!1){i();return}let o=this.view.refs.dialog,n=T(this.state),s=n?this.currentLiElement():null,r=O(),m=this.currentImgElement(),p=null;if(m){let f=getComputedStyle(m).transform;f&&f!=="none"&&(m.style.transform=f,p=m.style.transform)}if(s&&n){let f=e==="top"?-r:r;s.style.transform=`translate(${n.translateX}px,${n.translateY+f}px)`}let c=f=>{this.finishHideEffect===c&&(f&&f.target!==o||(this.finishHideEffect=null,o.removeEventListener("transitionend",c,!0),m&&p&&m.style.transform===p&&(m.style.transform=""),i()))};this.finishHideEffect=c,o.addEventListener("transitionend",c,!0),this.scheduleTimeout(c,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var n;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(n=e.src)!=null?n:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=I(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,n=[];for(let s=i-o;s<i+o;s++){let r=e[s];r&&!r.loaded&&n.push(this.loadItem(r))}n.length&&Promise.all(n).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.updateViewportHeight(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=T(this.state);this.state.viewer.onMove=!1,xe(this.state),this.state.viewer.isOpen&&this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(n=>n!==o),e()},i);return this.timeouts.push(o),o}applyAutoIconContrast(){let e=this.view.refs.dialog,i=getComputedStyle(e);if(i.getPropertyValue("--smartphoto-icon-color").trim())return;let o=i.getPropertyValue("--smartphoto-backdrop-color").trim();o&&e.style.setProperty("--smartphoto-icon-color",De(o))}fireEvent(e){Oe(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:e=>{let i=this.currentImgElement();!!i&&e instanceof Node&&i.contains(e)&&this.canZoomCurrentPhoto()?this.zoomPhoto():this.hidePhoto()},onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},onPinchClose:()=>this.hidePhoto(),onPhotoDragMove:()=>this.view.updatePhotoTransform(this.state),onPhotoDragEnd:e=>{if(e==="zoom-out"){this.zoomOutPhoto();return}if(e==="prev"){this.gotoSlide(this.state.viewer.prev);return}if(e==="next"){this.gotoSlide(this.state.viewer.next);return}this.view.updatePhotoTransform(this.state)}}}};var ft=ie;return rt(vt);})();
7
7
  SmartPhoto = SmartPhoto.default;
package/lib/smartphoto.js CHANGED
@@ -82,6 +82,10 @@ var getWindowWidth = () => {
82
82
  var getWindowHeight = () => {
83
83
  const visualViewport = window.visualViewport;
84
84
  if (visualViewport) {
85
+ const layoutWidth = document.documentElement.clientWidth;
86
+ if (visualViewport.width > 0 && layoutWidth > 0) {
87
+ return visualViewport.height * (layoutWidth / visualViewport.width);
88
+ }
85
89
  return visualViewport.height * visualViewport.scale;
86
90
  }
87
91
  return document.documentElement.clientHeight;
@@ -56,6 +56,10 @@ var getWindowWidth = () => {
56
56
  var getWindowHeight = () => {
57
57
  const visualViewport = window.visualViewport;
58
58
  if (visualViewport) {
59
+ const layoutWidth = document.documentElement.clientWidth;
60
+ if (visualViewport.width > 0 && layoutWidth > 0) {
61
+ return visualViewport.height * (layoutWidth / visualViewport.width);
62
+ }
59
63
  return visualViewport.height * visualViewport.scale;
60
64
  }
61
65
  return document.documentElement.clientHeight;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smartphoto",
3
- "version": "2.1.17",
3
+ "version": "2.1.18",
4
4
  "description": "smartphoto",
5
5
  "homepage": "https://developer.a-blogcms.jp",
6
6
  "main": "./lib/smartphoto.js",