smartphoto 2.1.16 → 2.1.17

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.16
2
+ * SmartPhoto v2.1.17
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
@@ -370,8 +370,9 @@
370
370
  maxY: round(maxY, 6) / item.scale
371
371
  };
372
372
  }
373
+ var FIT_MARGIN = 24;
373
374
  function sizeItems(items, winWidth, winHeight, headerHeight, footerHeight) {
374
- const screenY = winHeight - (headerHeight + footerHeight);
375
+ const screenY = winHeight - (headerHeight + footerHeight) - FIT_MARGIN * 2;
375
376
  items.forEach((item) => {
376
377
  if (!item.loaded) {
377
378
  return;
@@ -1073,13 +1074,14 @@
1073
1074
  refs.caption.focus();
1074
1075
  }
1075
1076
  }
1076
- function render(state) {
1077
+ function render(state, options2) {
1077
1078
  const { viewer } = state;
1078
1079
  refs.count.textContent = `${viewer.currentIndex + 1}/${viewer.total}`;
1079
1080
  refs.slides.forEach((rawSlideRefs, item) => {
1080
1081
  var _a;
1081
1082
  const slideRefs = upgradeIfProcessed(item, rawSlideRefs);
1082
1083
  const isCurrent = item.index === viewer.currentIndex;
1084
+ slideRefs.li.style.transition = (options2 == null ? void 0 : options2.immediate) ? "none" : "";
1083
1085
  slideRefs.li.style.transform = `translate(${item.translateX}px,${item.translateY}px)`;
1084
1086
  slideRefs.li.classList.toggle("current", isCurrent);
1085
1087
  if (isCurrent) {
@@ -1339,7 +1341,7 @@
1339
1341
  this.resetTranslateCurrent();
1340
1342
  this.setPosByCurrentIndex();
1341
1343
  this.setSizeByScreen();
1342
- this.commit();
1344
+ this.commit(true);
1343
1345
  };
1344
1346
  this.handleResize = () => {
1345
1347
  if (!this.state.viewer.isOpen || !currentItems(this.state)) {
@@ -1353,7 +1355,7 @@
1353
1355
  this.resetTranslateCurrent();
1354
1356
  this.setPosByCurrentIndex();
1355
1357
  this.setSizeByScreen();
1356
- this.commit();
1358
+ this.commit(true);
1357
1359
  };
1358
1360
  this.handleKeydown = (e) => {
1359
1361
  if (!this.state.viewer.isOpen) {
@@ -1381,21 +1383,22 @@
1381
1383
  this.setPosByCurrentIndex();
1382
1384
  this.setHashByCurrentIndex();
1383
1385
  this.setSizeByScreen();
1384
- this.commit();
1386
+ this.commit(true);
1385
1387
  const prevWidth = getWindowWidth2();
1388
+ const prevHeight = getWindowHeight2();
1386
1389
  const timeout = 500;
1387
1390
  const poll = (time) => {
1388
1391
  this.scheduleTimeout(() => {
1389
1392
  if (!this.state.viewer.isOpen) {
1390
1393
  return;
1391
1394
  }
1392
- if (prevWidth !== getWindowWidth2()) {
1395
+ if (prevWidth !== getWindowWidth2() || prevHeight !== getWindowHeight2()) {
1393
1396
  this.updateViewportHeight();
1394
1397
  this.resetTranslateCurrent();
1395
1398
  this.setPosByCurrentIndex();
1396
1399
  this.setHashByCurrentIndex();
1397
1400
  this.setSizeByScreen();
1398
- this.commit();
1401
+ this.commit(true);
1399
1402
  } else if (time <= timeout) {
1400
1403
  poll(time + 25);
1401
1404
  }
@@ -1812,8 +1815,8 @@
1812
1815
  dialog.style.display = "none";
1813
1816
  }
1814
1817
  }
1815
- commit() {
1816
- this.view.render(this.state);
1818
+ commit(immediate = false) {
1819
+ this.view.render(this.state, { immediate });
1817
1820
  this.view.updatePhotoTransform(this.state);
1818
1821
  this.syncDialog();
1819
1822
  }
@@ -1892,7 +1895,7 @@
1892
1895
  this.resetTranslateCurrent();
1893
1896
  this.setPosByCurrentIndex();
1894
1897
  this.setSizeByScreen();
1895
- this.commit();
1898
+ this.commit(true);
1896
1899
  return;
1897
1900
  }
1898
1901
  this.pendingViewTransitionResync = false;
@@ -2032,7 +2035,7 @@
2032
2035
  this.resetTranslateCurrent();
2033
2036
  this.setPosByCurrentIndex();
2034
2037
  this.setSizeByScreen();
2035
- this.commit();
2038
+ this.commit(true);
2036
2039
  });
2037
2040
  }
2038
2041
  openPhoto(item, trigger) {
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * SmartPhoto v2.1.16
2
+ * SmartPhoto v2.1.17
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 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({},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 Z(t){return t.getAttribute("data-group")||"nogroup"}function Ee(t){return t.group||"nogroup"}function Pe(t,e,i,o){let n=Z(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,S,P,H;let o=Ee(t),n=t.src,s=(c=t.thumb)!=null?c:n,r=(f=t.caption)!=null?f:null,m=(P=(S=t.alt)!=null?S:r)!=null?P: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:(H=t.id)!=null?H: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 U(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}}function We(t,e,i,o,n){let s=i-(o+n);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 ee(t,e){let i=10**e;return Math.round(t*i)/i}function J(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 nt=10;function rt(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,S=null,P=!1,H=null,C=null,z=0,G=0,V=!1,O=0,N=1,M=null,u=0,B=0;function _(){return ae()}function j(l){let{width:h,height:g}=Ie();return Fe(l,t.viewer,h,g)}function ie(l){let{width:h,height:g}=Ie();return U(l,h,g,_())}function $(l){return t.options.resizeStyle==="fill"&&_()?ie(l):1}let oe=4;function de(l){return Math.max(oe,ie(l))}let me=.75;function ne(l,h){let g=L(t),y=j(g);t.viewer.elastic=!0,l===1?t.viewer.photoPosX=y.minX:l===-1&&(t.viewer.photoPosX=y.maxX),h===1?t.viewer.photoPosY=y.minY:h===-1&&(t.viewer.photoPosY=y.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let pe=setInterval(()=>{if(V||s||P||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=u,t.viewer.photoPosY+=B;let l=L(t);if(!l)return;let h=j(l);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,B*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,B*=-.2);let g=rt(u,B),y=g.force-t.options.registance;y<.5||(u=Math.cos(g.theta)*y,B=Math.sin(g.theta)*y,e.onPhotoDragMove())},t.options.forceInterval);function q(l,h){(l>5||l<-5)&&(u+=l*.05),t.options.verticalGravity&&(h>5||h<-5)&&(B+=h*.05)}function fe(l){if(!(l!=null&&l.gamma)||t.viewer.appearEffect||V||s||P||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?q(l.gamma,l.beta):h===90?q(l.beta,l.gamma):h===-90?q(-l.beta,-l.gamma):h===180&&q(-l.gamma,-l.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",fe,{signal:i});function re(){let l=Array.from(o.values());O=ke(l[0],l[1]),N=t.viewer.scaleSize}function ve(){V=!0,s=!1,P=!1,re(),u=0,B=0,t.viewer.scale=!0,t.viewer.hideUi=!0,e.onGestureStart()}function d(l){let h=J(l);s=!0,r=!0,m=h,p=h,f=Date.now(),S=l.target}function a(l){P=!0;let h=J(l);C=h,H=h}function E(l){var h,g;try{(g=(h=l.currentTarget).setPointerCapture)==null||g.call(h,l.pointerId)}catch(y){}if(o.set(l.pointerId,J(l)),o.size>1){ve();return}if(t.viewer.scale){a(l);return}d(l)}function v(){M===null&&(M=requestAnimationFrame(()=>{M=null,e.onGestureMove()}))}function w(){M!==null&&(cancelAnimationFrame(M),M=null,e.onGestureMove())}function x(){let l=Array.from(o.values()),h=l[0],g=l[1],y=ke(h,g);if(O===0){O=y,N=t.viewer.scaleSize,v();return}let b=t.viewer.scaleSize;t.viewer.scaleSize=ee(N*y/O,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2);let A=L(t);if(A&&t.viewer.scaleSize!==b){let{width:W,height:ge}=Ie(),K=W/2,R=t.options.headerHeight+(ge-t.options.headerHeight-t.options.footerHeight)/2,Q=A.scale,k={x:(h.x+g.x)/2,y:(h.y+g.y)/2},Ae=t.viewer.scaleSize/b,Ze=k.x-(K+t.viewer.photoPosX*Q),et=k.y-(R+t.viewer.photoPosY*Q);t.viewer.photoPosX=ee((k.x-Ze*Ae-K)/Q,6),t.viewer.photoPosY=ee((k.y-et*Ae-R)/Q,6)}v()}function D(l){let h=J(l),g=h.x-p.x,y=h.y-m.y;r&&(e.onSwipeStart(),r=!1,c=Math.abs(g)>Math.abs(y)?"horizontal":"vertical"),c==="horizontal"?t.viewer.translateX+=g:t.viewer.translateY=y,p=h,e.onSwipeMove()}function se(l){let h=J(l),g=h.x-C.x,y=h.y-C.y,b=ee(t.viewer.scaleSize*g,6),A=ee(t.viewer.scaleSize*y,6);t.viewer.photoPosX+=b,z=b,t.viewer.photoPosY+=A,G=A,C=h,e.onPhotoDragMove()}function X(l){if(o.has(l.pointerId)){if(o.set(l.pointerId,J(l)),V){x();return}if(P){se(l);return}D(l)}}function F(){V=!1,w();let l=L(t);if(!l)return;let h=$(l);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(l));let g=j(l),y=0,b=0;t.viewer.photoPosX>g.maxX?y=-1:t.viewer.photoPosX<g.minX&&(y=1),t.viewer.photoPosY>g.maxY?b=-1:t.viewer.photoPosY<g.minY&&(b=1),(y!==0||b!==0)&&ne(y,b),t.viewer.scale=!0,t.viewer.hideUi=!0,e.onGestureEnd()}function we(){var K;s=!1;let l=m,h=p,g=Date.now(),y=n-g,b=h.x-l.x,A=h.y-l.y,W=b===0&&A===0;if(!_()&&W){e.onTap(S);return}if(Math.abs(y)<=500&&W){e.onTap(S);return}n=g;let ge=(K=I(t))!=null?K:[];if(c==="horizontal"){let R="stay",Q=Math.max(g-f,1),k=Math.abs(b)>=nt&&Math.abs(b)/Q>=t.options.swipeVelocity;(b>=t.options.swipeOffset||k&&b>0)&&t.viewer.currentIndex!==0?R="prev":(b<=-t.options.swipeOffset||k&&b<0)&&t.viewer.currentIndex!==ge.length-1&&(R="next"),e.onSwipeEnd(R)}else{let R="stay";t.options.swipeBottomToClose&&A>=t.options.swipeOffset?R="close-bottom":t.options.swipeTopToClose&&A<=-t.options.swipeOffset&&(R="close-top"),e.onSwipeEnd(R)}}function Qe(){P=!1;let l=C,h=H;if(l.x===h.x&&l.y===h.y){e.onPhotoDragEnd("zoom-out");return}let g=L(t);if(!g){e.onPhotoDragEnd(null);return}let y=j(g),b=t.options.swipeOffset*t.viewer.scaleSize,A=0,W=0;if(t.viewer.photoPosX>y.maxX?A=-1:t.viewer.photoPosX<y.minX&&(A=1),t.viewer.photoPosY>y.maxY?W=-1:t.viewer.photoPosY<y.minY&&(W=1),t.viewer.photoPosX-y.maxX>b&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(y.minX-t.viewer.photoPosX>b&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}A===0&&W===0?(u=z/5,B=G/5):ne(A,W),e.onPhotoDragEnd(null)}function Ce(l){if(o.delete(l.pointerId),V){o.size<2?(F(),o.clear()):re();return}if(P){Qe();return}s&&we()}function Je(...l){for(let h of l)h.addEventListener("pointerdown",E,{signal:i}),h.addEventListener("pointermove",X,{signal:i}),h.addEventListener("pointerup",Ce,{signal:i}),h.addEventListener("pointercancel",Ce,{signal:i})}function Ke(){clearInterval(pe),M!==null&&(cancelAnimationFrame(M),M=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 st(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 S=document.createElement("span");S.className=n.smartPhotoCount;let P=document.createElement("h1");P.id=`smartphoto-${t}-title`,P.className=n.smartPhotoCaption,P.setAttribute("tabindex","-1");let H=document.createElement("button");H.className=n.smartPhotoDismiss,H.appendChild(ce(s.closeDialog)),H.addEventListener("click",()=>i.onDismiss(),{signal:o}),f.append(S,P,H);let C=document.createElement("div");C.className=n.smartPhotoContent,C.addEventListener("click",d=>{d.target===C&&i.onBackdropClick()},{signal:o});let z=document.createElement("ul");z.className=n.smartPhotoList,z.setAttribute("role","region"),z.setAttribute("aria-roledescription","carousel"),z.setAttribute("aria-label",s.carouselLabel),z.setAttribute("aria-live","polite"),z.setAttribute("aria-atomic","false"),c.append(f,C,z);let G=null,V=null,O=null;if(e.arrows){G=document.createElement("ul"),G.className=n.smartPhotoArrows,V=document.createElement("li"),V.className=n.smartPhotoArrowLeft;let d=Le();d.appendChild(ce(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(d),O=document.createElement("li"),O.className=n.smartPhotoArrowRight;let a=Le();a.appendChild(ce(s.gotoNextImage)),a.addEventListener("click",()=>i.onNext(),{signal:o}),O.appendChild(a),G.append(V,O),c.appendChild(G)}let N=null,M=null;e.nav&&(N=document.createElement("nav"),N.className=n.smartPhotoNav,N.setAttribute("aria-label","Choose slide to display"),M=document.createElement("ul"),N.appendChild(M),c.appendChild(N)),p.appendChild(c),m.appendChild(p),r.appendChild(m);let u={dialog:m,count:S,caption:P,dismiss:H,content:C,list:z,arrows:G,arrowLeft:V,arrowRight:O,nav:N,navList:M,slides:new Map,imgClone:null};function B(){let d=document.createElement("div");d.className=n.smartPhotoLoaderWrap;let a=document.createElement("span");return a.className=n.smartPhotoLoader,d.appendChild(a),d}function _(d){var v,w;let a=document.createElement("div");a.className=n.smartPhotoImgWrap;let E=document.createElement("img");return E.className=n.smartPhotoImg,E.src=(v=d.src)!=null?v:"",E.alt=(w=d.alt)!=null?w:"",E.addEventListener("dragstart",x=>x.preventDefault(),{signal:o}),a.appendChild(E),{imgWrap:a,img:E}}function j(d,a){var E;u.list.replaceChildren(),(E=u.navList)==null||E.replaceChildren(),u.slides=new Map,d.forEach(v=>{var D,se;let w=document.createElement("li");w.setAttribute("role","group"),w.setAttribute("aria-roledescription","slide"),w.setAttribute("aria-label",`${v.index+1} of ${d.length}`);let x={li:w,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(v.processed){let{imgWrap:X,img:F}=_(v);w.appendChild(X),x.imgWrap=X,x.img=F}else{let X=B();w.appendChild(X),x.loaderWrap=X}if(u.list.appendChild(w),u.slides.set(v,x),u.navList){let X=document.createElement("li"),F=Le();F.style.backgroundImage=`url("${st((D=v.thumb)!=null?D:"")}")`;let we=v.index;F.addEventListener("click",()=>i.onNavigate(we),{signal:o}),F.appendChild(ce(`go to ${(se=v.caption)!=null?se:""}`)),X.appendChild(F),u.navList.appendChild(X),x.navLink=F}}),oe(a)}function ie(d,a){var w;if(a.imgWrap||!d.processed)return a;let{imgWrap:E,img:v}=_(d);return(w=a.loaderWrap)==null||w.replaceWith(E),a.loaderWrap=null,a.imgWrap=E,a.img=v,a}function $(d){d&&document.activeElement&&d.contains(document.activeElement)&&u.caption.focus()}function oe(d){let{viewer:a}=d;u.count.textContent=`${a.currentIndex+1}/${a.total}`,u.slides.forEach((E,v)=>{var D;let w=ie(v,E),x=v.index===a.currentIndex;w.li.style.transform=`translate(${v.translateX}px,${v.translateY}px)`,w.li.classList.toggle("current",x),x?w.li.removeAttribute("aria-hidden"):w.li.setAttribute("aria-hidden","true"),x&&(u.caption.textContent=(D=v.caption)!=null?D:""),w.imgWrap&&w.img&&(w.imgWrap.style.transform=`translate(${v.x}px,${v.y}px) scale(${v.scale})`,w.img.style.width=`${v.width}px`,x||(w.img.style.transform="translate(0px,0px) scale(1)"),w.img.classList.toggle("active",a.appear),w.img.classList.toggle(n.smartPhotoImgOnMove,a.scale),w.img.classList.toggle(n.smartPhotoImgElasticMove,a.elastic)),w.navLink&&(w.navLink.classList.toggle("current",x),x?w.navLink.setAttribute("aria-current","true"):w.navLink.removeAttribute("aria-current"))}),u.arrowLeft&&(a.showPrevArrow?u.arrowLeft.removeAttribute("aria-hidden"):($(u.arrowLeft),u.arrowLeft.setAttribute("aria-hidden","true"))),u.arrowRight&&(a.showNextArrow?u.arrowRight.removeAttribute("aria-hidden"):($(u.arrowRight),u.arrowRight.setAttribute("aria-hidden","true"))),u.arrows&&(a.hideUi&&$(u.arrows),u.arrows.setAttribute("aria-hidden",a.hideUi?"true":"false")),u.nav&&(a.hideUi&&$(u.nav),u.nav.setAttribute("aria-hidden",a.hideUi?"true":"false"))}function de(d){for(let[a,E]of u.slides)if(a.index===d.viewer.currentIndex)return E;return null}function me(d){let{viewer:a}=d,E=de(d),v=E==null?void 0:E.img;v&&(v.style.transform=`translate(${a.photoPosX}px,${a.photoPosY}px) scale(${a.scaleSize})`,v.classList.toggle(n.smartPhotoImgOnMove,a.scale),v.classList.toggle(n.smartPhotoImgElasticMove,a.elastic)),u.nav&&(a.hideUi&&$(u.nav),u.nav.setAttribute("aria-hidden",a.hideUi?"true":"false")),u.arrows&&(a.hideUi&&$(u.arrows),u.arrows.setAttribute("aria-hidden",a.hideUi?"true":"false"))}function ne(d){let{viewer:a}=d;u.list.style.transform=`translate(${a.translateX}px,${a.translateY}px)`,u.list.classList.toggle(n.smartPhotoListOnMove,a.onMove)}function pe(d){for(let[a,E]of u.slides){if(a.index!==d.viewer.currentIndex)continue;let{img:v,imgWrap:w}=E;if(!v||!w||!a.width||!a.scale||a.scale>=1)return;let x=v.getBoundingClientRect();v.style.width=`${a.width*a.scale}px`,w.style.transform=`translate(${a.x}px,${a.y}px) scale(1)`;let D=v.getBoundingClientRect();w.style.transform=`translate(${a.x+x.left-D.left}px,${a.y+x.top-D.top}px) scale(1)`;return}}function q(){for(let[d,a]of u.slides){let{img:E,imgWrap:v}=a;E&&v&&(v.style.transform=`translate(${d.x}px,${d.y}px) scale(${d.scale})`,E.style.width=`${d.width}px`)}}function fe(d){let a=document.createElement("img");a.className=n.smartPhotoImgClone,a.src=d.img,a.style.width=`${d.width}px`,a.style.height=`${d.height}px`,a.style.transform=`translate(${d.left}px,${d.top}px) scale(1)`,p.appendChild(a),u.imgClone=a}function re(){var d;(d=u.imgClone)==null||d.remove(),u.imgClone=null}function ve(){r.remove()}return{root:r,refs:u,render:oe,syncSlides:j,updatePhotoTransform:me,applyViewTransitionLayout:pe,resetViewTransitionLayout:q,updateListTransform:ne,showAppearEffect:fe,removeAppearEffect:re,destroy:ve}}var T=le,Y=he;function at(t){return t.length>0&&t[0]instanceof Element}function lt(){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 te=class{constructor(e,i){this.id=lt();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=Z(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",`${Y()}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()}};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()}};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();let e=T(),i=500,o=n=>{this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(e!==T()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):n<=i&&o(n+25))},25)};o(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=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=U(e,T(),Y(),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&&U(e,T(),Y(),this.isSmartPhoneFlag)>1}zoomOutPhoto(){let e=L(this.state),i=this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag&&e?U(e,T(),Y(),!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(S=>S.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)&&!at(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=Z(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=>Z(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 S=s.get(c);if(S)return S.index!==f&&(r=!0,S.index=f),S;r=!0;let P=Pe(c,this.state.options,f,T());return this.itemsByElement.set(c,P),P});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&&(We(e,T(),Y(),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(){this.view.render(this.state),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=U(e,T(),Y(),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();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=Y(),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 S=(f-1)/2*s+(m-s*f)/2,P=(f-1)/2*r+(p-r*f)/2,H=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:r,top:n.top,left:n.left,once:!0,img:H||i.src||"",afterX:S,afterY:P,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=Y();requestAnimationFrame(()=>{if(this.state.viewer.isOpen&&!(T()===e&&Y()===i)){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}})}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=Y(),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=te;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 Et=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;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;})();
package/js/smartphoto.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * SmartPhoto v2.1.16
2
+ * SmartPhoto v2.1.17
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
@@ -394,8 +394,9 @@ var SmartPhoto = (() => {
394
394
  maxY: round(maxY, 6) / item.scale
395
395
  };
396
396
  }
397
+ var FIT_MARGIN = 24;
397
398
  function sizeItems(items, winWidth, winHeight, headerHeight, footerHeight) {
398
- const screenY = winHeight - (headerHeight + footerHeight);
399
+ const screenY = winHeight - (headerHeight + footerHeight) - FIT_MARGIN * 2;
399
400
  items.forEach((item) => {
400
401
  if (!item.loaded) {
401
402
  return;
@@ -1097,13 +1098,14 @@ var SmartPhoto = (() => {
1097
1098
  refs.caption.focus();
1098
1099
  }
1099
1100
  }
1100
- function render(state) {
1101
+ function render(state, options2) {
1101
1102
  const { viewer } = state;
1102
1103
  refs.count.textContent = `${viewer.currentIndex + 1}/${viewer.total}`;
1103
1104
  refs.slides.forEach((rawSlideRefs, item) => {
1104
1105
  var _a;
1105
1106
  const slideRefs = upgradeIfProcessed(item, rawSlideRefs);
1106
1107
  const isCurrent = item.index === viewer.currentIndex;
1108
+ slideRefs.li.style.transition = (options2 == null ? void 0 : options2.immediate) ? "none" : "";
1107
1109
  slideRefs.li.style.transform = `translate(${item.translateX}px,${item.translateY}px)`;
1108
1110
  slideRefs.li.classList.toggle("current", isCurrent);
1109
1111
  if (isCurrent) {
@@ -1363,7 +1365,7 @@ var SmartPhoto = (() => {
1363
1365
  this.resetTranslateCurrent();
1364
1366
  this.setPosByCurrentIndex();
1365
1367
  this.setSizeByScreen();
1366
- this.commit();
1368
+ this.commit(true);
1367
1369
  };
1368
1370
  this.handleResize = () => {
1369
1371
  if (!this.state.viewer.isOpen || !currentItems(this.state)) {
@@ -1377,7 +1379,7 @@ var SmartPhoto = (() => {
1377
1379
  this.resetTranslateCurrent();
1378
1380
  this.setPosByCurrentIndex();
1379
1381
  this.setSizeByScreen();
1380
- this.commit();
1382
+ this.commit(true);
1381
1383
  };
1382
1384
  this.handleKeydown = (e) => {
1383
1385
  if (!this.state.viewer.isOpen) {
@@ -1405,21 +1407,22 @@ var SmartPhoto = (() => {
1405
1407
  this.setPosByCurrentIndex();
1406
1408
  this.setHashByCurrentIndex();
1407
1409
  this.setSizeByScreen();
1408
- this.commit();
1410
+ this.commit(true);
1409
1411
  const prevWidth = getWindowWidth2();
1412
+ const prevHeight = getWindowHeight2();
1410
1413
  const timeout = 500;
1411
1414
  const poll = (time) => {
1412
1415
  this.scheduleTimeout(() => {
1413
1416
  if (!this.state.viewer.isOpen) {
1414
1417
  return;
1415
1418
  }
1416
- if (prevWidth !== getWindowWidth2()) {
1419
+ if (prevWidth !== getWindowWidth2() || prevHeight !== getWindowHeight2()) {
1417
1420
  this.updateViewportHeight();
1418
1421
  this.resetTranslateCurrent();
1419
1422
  this.setPosByCurrentIndex();
1420
1423
  this.setHashByCurrentIndex();
1421
1424
  this.setSizeByScreen();
1422
- this.commit();
1425
+ this.commit(true);
1423
1426
  } else if (time <= timeout) {
1424
1427
  poll(time + 25);
1425
1428
  }
@@ -1836,8 +1839,8 @@ var SmartPhoto = (() => {
1836
1839
  dialog.style.display = "none";
1837
1840
  }
1838
1841
  }
1839
- commit() {
1840
- this.view.render(this.state);
1842
+ commit(immediate = false) {
1843
+ this.view.render(this.state, { immediate });
1841
1844
  this.view.updatePhotoTransform(this.state);
1842
1845
  this.syncDialog();
1843
1846
  }
@@ -1916,7 +1919,7 @@ var SmartPhoto = (() => {
1916
1919
  this.resetTranslateCurrent();
1917
1920
  this.setPosByCurrentIndex();
1918
1921
  this.setSizeByScreen();
1919
- this.commit();
1922
+ this.commit(true);
1920
1923
  return;
1921
1924
  }
1922
1925
  this.pendingViewTransitionResync = false;
@@ -2056,7 +2059,7 @@ var SmartPhoto = (() => {
2056
2059
  this.resetTranslateCurrent();
2057
2060
  this.setPosByCurrentIndex();
2058
2061
  this.setSizeByScreen();
2059
- this.commit();
2062
+ this.commit(true);
2060
2063
  });
2061
2064
  }
2062
2065
  openPhoto(item, trigger) {
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * SmartPhoto v2.1.16
2
+ * SmartPhoto v2.1.17
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 ft={};ot(ft,{default:()=>pt});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 J(t){return t.getAttribute("data-group")||"nogroup"}function Pe(t){return t.group||"nogroup"}function be(t,e,i,o){let n=J(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,S,P,H;let o=Pe(t),n=t.src,s=(c=t.thumb)!=null?c:n,r=(f=t.caption)!=null?f:null,m=(P=(S=t.alt)!=null?S:r)!=null?P: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:(H=t.id)!=null?H: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 U(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}}function We(t,e,i,o,n){let s=i-(o+n);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 ee(t,e){let i=10**e;return Math.round(t*i)/i}function Q(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 ht=10;function ut(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,S=null,P=!1,H=null,C=null,z=0,G=0,V=!1,O=0,N=1,M=null,u=0,B=0;function _(){return ae()}function q(l){let{width:h,height:g}=Te();return Fe(l,t.viewer,h,g)}function ie(l){let{width:h,height:g}=Te();return U(l,h,g,_())}function $(l){return t.options.resizeStyle==="fill"&&_()?ie(l):1}let oe=4;function de(l){return Math.max(oe,ie(l))}let me=.75;function ne(l,h){let g=T(t),y=q(g);t.viewer.elastic=!0,l===1?t.viewer.photoPosX=y.minX:l===-1&&(t.viewer.photoPosX=y.maxX),h===1?t.viewer.photoPosY=y.minY:h===-1&&(t.viewer.photoPosY=y.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let pe=setInterval(()=>{if(V||s||P||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=u,t.viewer.photoPosY+=B;let l=T(t);if(!l)return;let h=q(l);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,B*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,B*=-.2);let g=ut(u,B),y=g.force-t.options.registance;y<.5||(u=Math.cos(g.theta)*y,B=Math.sin(g.theta)*y,e.onPhotoDragMove())},t.options.forceInterval);function j(l,h){(l>5||l<-5)&&(u+=l*.05),t.options.verticalGravity&&(h>5||h<-5)&&(B+=h*.05)}function fe(l){if(!(l!=null&&l.gamma)||t.viewer.appearEffect||V||s||P||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?j(l.gamma,l.beta):h===90?j(l.beta,l.gamma):h===-90?j(-l.beta,-l.gamma):h===180&&j(-l.gamma,-l.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",fe,{signal:i});function re(){let l=Array.from(o.values());O=ke(l[0],l[1]),N=t.viewer.scaleSize}function ve(){V=!0,s=!1,P=!1,re(),u=0,B=0,t.viewer.scale=!0,t.viewer.hideUi=!0,e.onGestureStart()}function d(l){let h=Q(l);s=!0,r=!0,m=h,p=h,f=Date.now(),S=l.target}function a(l){P=!0;let h=Q(l);C=h,H=h}function E(l){var h,g;try{(g=(h=l.currentTarget).setPointerCapture)==null||g.call(h,l.pointerId)}catch(y){}if(o.set(l.pointerId,Q(l)),o.size>1){ve();return}if(t.viewer.scale){a(l);return}d(l)}function v(){M===null&&(M=requestAnimationFrame(()=>{M=null,e.onGestureMove()}))}function w(){M!==null&&(cancelAnimationFrame(M),M=null,e.onGestureMove())}function x(){let l=Array.from(o.values()),h=l[0],g=l[1],y=ke(h,g);if(O===0){O=y,N=t.viewer.scaleSize,v();return}let b=t.viewer.scaleSize;t.viewer.scaleSize=ee(N*y/O,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2);let A=T(t);if(A&&t.viewer.scaleSize!==b){let{width:W,height:ge}=Te(),Z=W/2,R=t.options.headerHeight+(ge-t.options.headerHeight-t.options.footerHeight)/2,K=A.scale,k={x:(h.x+g.x)/2,y:(h.y+g.y)/2},Ae=t.viewer.scaleSize/b,Ze=k.x-(Z+t.viewer.photoPosX*K),Je=k.y-(R+t.viewer.photoPosY*K);t.viewer.photoPosX=ee((k.x-Ze*Ae-Z)/K,6),t.viewer.photoPosY=ee((k.y-Je*Ae-R)/K,6)}v()}function D(l){let h=Q(l),g=h.x-p.x,y=h.y-m.y;r&&(e.onSwipeStart(),r=!1,c=Math.abs(g)>Math.abs(y)?"horizontal":"vertical"),c==="horizontal"?t.viewer.translateX+=g:t.viewer.translateY=y,p=h,e.onSwipeMove()}function se(l){let h=Q(l),g=h.x-C.x,y=h.y-C.y,b=ee(t.viewer.scaleSize*g,6),A=ee(t.viewer.scaleSize*y,6);t.viewer.photoPosX+=b,z=b,t.viewer.photoPosY+=A,G=A,C=h,e.onPhotoDragMove()}function X(l){if(o.has(l.pointerId)){if(o.set(l.pointerId,Q(l)),V){x();return}if(P){se(l);return}D(l)}}function F(){V=!1,w();let l=T(t);if(!l)return;let h=$(l);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(l));let g=q(l),y=0,b=0;t.viewer.photoPosX>g.maxX?y=-1:t.viewer.photoPosX<g.minX&&(y=1),t.viewer.photoPosY>g.maxY?b=-1:t.viewer.photoPosY<g.minY&&(b=1),(y!==0||b!==0)&&ne(y,b),t.viewer.scale=!0,t.viewer.hideUi=!0,e.onGestureEnd()}function we(){var Z;s=!1;let l=m,h=p,g=Date.now(),y=n-g,b=h.x-l.x,A=h.y-l.y,W=b===0&&A===0;if(!_()&&W){e.onTap(S);return}if(Math.abs(y)<=500&&W){e.onTap(S);return}n=g;let ge=(Z=I(t))!=null?Z:[];if(c==="horizontal"){let R="stay",K=Math.max(g-f,1),k=Math.abs(b)>=ht&&Math.abs(b)/K>=t.options.swipeVelocity;(b>=t.options.swipeOffset||k&&b>0)&&t.viewer.currentIndex!==0?R="prev":(b<=-t.options.swipeOffset||k&&b<0)&&t.viewer.currentIndex!==ge.length-1&&(R="next"),e.onSwipeEnd(R)}else{let R="stay";t.options.swipeBottomToClose&&A>=t.options.swipeOffset?R="close-bottom":t.options.swipeTopToClose&&A<=-t.options.swipeOffset&&(R="close-top"),e.onSwipeEnd(R)}}function je(){P=!1;let l=C,h=H;if(l.x===h.x&&l.y===h.y){e.onPhotoDragEnd("zoom-out");return}let g=T(t);if(!g){e.onPhotoDragEnd(null);return}let y=q(g),b=t.options.swipeOffset*t.viewer.scaleSize,A=0,W=0;if(t.viewer.photoPosX>y.maxX?A=-1:t.viewer.photoPosX<y.minX&&(A=1),t.viewer.photoPosY>y.maxY?W=-1:t.viewer.photoPosY<y.minY&&(W=1),t.viewer.photoPosX-y.maxX>b&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(y.minX-t.viewer.photoPosX>b&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}A===0&&W===0?(u=z/5,B=G/5):ne(A,W),e.onPhotoDragEnd(null)}function Ce(l){if(o.delete(l.pointerId),V){o.size<2?(F(),o.clear()):re();return}if(P){je();return}s&&we()}function Ke(...l){for(let h of l)h.addEventListener("pointerdown",E,{signal:i}),h.addEventListener("pointermove",X,{signal:i}),h.addEventListener("pointerup",Ce,{signal:i}),h.addEventListener("pointercancel",Ce,{signal:i})}function Qe(){clearInterval(pe),M!==null&&(cancelAnimationFrame(M),M=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 ct(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 S=document.createElement("span");S.className=n.smartPhotoCount;let P=document.createElement("h1");P.id=`smartphoto-${t}-title`,P.className=n.smartPhotoCaption,P.setAttribute("tabindex","-1");let H=document.createElement("button");H.className=n.smartPhotoDismiss,H.appendChild(ce(s.closeDialog)),H.addEventListener("click",()=>i.onDismiss(),{signal:o}),f.append(S,P,H);let C=document.createElement("div");C.className=n.smartPhotoContent,C.addEventListener("click",d=>{d.target===C&&i.onBackdropClick()},{signal:o});let z=document.createElement("ul");z.className=n.smartPhotoList,z.setAttribute("role","region"),z.setAttribute("aria-roledescription","carousel"),z.setAttribute("aria-label",s.carouselLabel),z.setAttribute("aria-live","polite"),z.setAttribute("aria-atomic","false"),c.append(f,C,z);let G=null,V=null,O=null;if(e.arrows){G=document.createElement("ul"),G.className=n.smartPhotoArrows,V=document.createElement("li"),V.className=n.smartPhotoArrowLeft;let d=Le();d.appendChild(ce(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(d),O=document.createElement("li"),O.className=n.smartPhotoArrowRight;let a=Le();a.appendChild(ce(s.gotoNextImage)),a.addEventListener("click",()=>i.onNext(),{signal:o}),O.appendChild(a),G.append(V,O),c.appendChild(G)}let N=null,M=null;e.nav&&(N=document.createElement("nav"),N.className=n.smartPhotoNav,N.setAttribute("aria-label","Choose slide to display"),M=document.createElement("ul"),N.appendChild(M),c.appendChild(N)),p.appendChild(c),m.appendChild(p),r.appendChild(m);let u={dialog:m,count:S,caption:P,dismiss:H,content:C,list:z,arrows:G,arrowLeft:V,arrowRight:O,nav:N,navList:M,slides:new Map,imgClone:null};function B(){let d=document.createElement("div");d.className=n.smartPhotoLoaderWrap;let a=document.createElement("span");return a.className=n.smartPhotoLoader,d.appendChild(a),d}function _(d){var v,w;let a=document.createElement("div");a.className=n.smartPhotoImgWrap;let E=document.createElement("img");return E.className=n.smartPhotoImg,E.src=(v=d.src)!=null?v:"",E.alt=(w=d.alt)!=null?w:"",E.addEventListener("dragstart",x=>x.preventDefault(),{signal:o}),a.appendChild(E),{imgWrap:a,img:E}}function q(d,a){var E;u.list.replaceChildren(),(E=u.navList)==null||E.replaceChildren(),u.slides=new Map,d.forEach(v=>{var D,se;let w=document.createElement("li");w.setAttribute("role","group"),w.setAttribute("aria-roledescription","slide"),w.setAttribute("aria-label",`${v.index+1} of ${d.length}`);let x={li:w,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(v.processed){let{imgWrap:X,img:F}=_(v);w.appendChild(X),x.imgWrap=X,x.img=F}else{let X=B();w.appendChild(X),x.loaderWrap=X}if(u.list.appendChild(w),u.slides.set(v,x),u.navList){let X=document.createElement("li"),F=Le();F.style.backgroundImage=`url("${ct((D=v.thumb)!=null?D:"")}")`;let we=v.index;F.addEventListener("click",()=>i.onNavigate(we),{signal:o}),F.appendChild(ce(`go to ${(se=v.caption)!=null?se:""}`)),X.appendChild(F),u.navList.appendChild(X),x.navLink=F}}),oe(a)}function ie(d,a){var w;if(a.imgWrap||!d.processed)return a;let{imgWrap:E,img:v}=_(d);return(w=a.loaderWrap)==null||w.replaceWith(E),a.loaderWrap=null,a.imgWrap=E,a.img=v,a}function $(d){d&&document.activeElement&&d.contains(document.activeElement)&&u.caption.focus()}function oe(d){let{viewer:a}=d;u.count.textContent=`${a.currentIndex+1}/${a.total}`,u.slides.forEach((E,v)=>{var D;let w=ie(v,E),x=v.index===a.currentIndex;w.li.style.transform=`translate(${v.translateX}px,${v.translateY}px)`,w.li.classList.toggle("current",x),x?w.li.removeAttribute("aria-hidden"):w.li.setAttribute("aria-hidden","true"),x&&(u.caption.textContent=(D=v.caption)!=null?D:""),w.imgWrap&&w.img&&(w.imgWrap.style.transform=`translate(${v.x}px,${v.y}px) scale(${v.scale})`,w.img.style.width=`${v.width}px`,x||(w.img.style.transform="translate(0px,0px) scale(1)"),w.img.classList.toggle("active",a.appear),w.img.classList.toggle(n.smartPhotoImgOnMove,a.scale),w.img.classList.toggle(n.smartPhotoImgElasticMove,a.elastic)),w.navLink&&(w.navLink.classList.toggle("current",x),x?w.navLink.setAttribute("aria-current","true"):w.navLink.removeAttribute("aria-current"))}),u.arrowLeft&&(a.showPrevArrow?u.arrowLeft.removeAttribute("aria-hidden"):($(u.arrowLeft),u.arrowLeft.setAttribute("aria-hidden","true"))),u.arrowRight&&(a.showNextArrow?u.arrowRight.removeAttribute("aria-hidden"):($(u.arrowRight),u.arrowRight.setAttribute("aria-hidden","true"))),u.arrows&&(a.hideUi&&$(u.arrows),u.arrows.setAttribute("aria-hidden",a.hideUi?"true":"false")),u.nav&&(a.hideUi&&$(u.nav),u.nav.setAttribute("aria-hidden",a.hideUi?"true":"false"))}function de(d){for(let[a,E]of u.slides)if(a.index===d.viewer.currentIndex)return E;return null}function me(d){let{viewer:a}=d,E=de(d),v=E==null?void 0:E.img;v&&(v.style.transform=`translate(${a.photoPosX}px,${a.photoPosY}px) scale(${a.scaleSize})`,v.classList.toggle(n.smartPhotoImgOnMove,a.scale),v.classList.toggle(n.smartPhotoImgElasticMove,a.elastic)),u.nav&&(a.hideUi&&$(u.nav),u.nav.setAttribute("aria-hidden",a.hideUi?"true":"false")),u.arrows&&(a.hideUi&&$(u.arrows),u.arrows.setAttribute("aria-hidden",a.hideUi?"true":"false"))}function ne(d){let{viewer:a}=d;u.list.style.transform=`translate(${a.translateX}px,${a.translateY}px)`,u.list.classList.toggle(n.smartPhotoListOnMove,a.onMove)}function pe(d){for(let[a,E]of u.slides){if(a.index!==d.viewer.currentIndex)continue;let{img:v,imgWrap:w}=E;if(!v||!w||!a.width||!a.scale||a.scale>=1)return;let x=v.getBoundingClientRect();v.style.width=`${a.width*a.scale}px`,w.style.transform=`translate(${a.x}px,${a.y}px) scale(1)`;let D=v.getBoundingClientRect();w.style.transform=`translate(${a.x+x.left-D.left}px,${a.y+x.top-D.top}px) scale(1)`;return}}function j(){for(let[d,a]of u.slides){let{img:E,imgWrap:v}=a;E&&v&&(v.style.transform=`translate(${d.x}px,${d.y}px) scale(${d.scale})`,E.style.width=`${d.width}px`)}}function fe(d){let a=document.createElement("img");a.className=n.smartPhotoImgClone,a.src=d.img,a.style.width=`${d.width}px`,a.style.height=`${d.height}px`,a.style.transform=`translate(${d.left}px,${d.top}px) scale(1)`,p.appendChild(a),u.imgClone=a}function re(){var d;(d=u.imgClone)==null||d.remove(),u.imgClone=null}function ve(){r.remove()}return{root:r,refs:u,render:oe,syncSlides:q,updatePhotoTransform:me,applyViewTransitionLayout:pe,resetViewTransitionLayout:j,updateListTransform:ne,showAppearEffect:fe,removeAppearEffect:re,destroy:ve}}var L=le,Y=he;function dt(t){return t.length>0&&t[0]instanceof Element}function mt(){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 te=class{constructor(e,i){this.id=mt();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=J(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",`${Y()}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()}};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()}};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();let e=L(),i=500,o=n=>{this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(e!==L()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):n<=i&&o(n+25))},25)};o(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=U(e,L(),Y(),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&&U(e,L(),Y(),this.isSmartPhoneFlag)>1}zoomOutPhoto(){let e=T(this.state),i=this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag&&e?U(e,L(),Y(),!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(S=>S.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)&&!dt(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=J(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=>J(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 S=s.get(c);if(S)return S.index!==f&&(r=!0,S.index=f),S;r=!0;let P=be(c,this.state.options,f,L());return this.itemsByElement.set(c,P),P});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&&(We(e,L(),Y(),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(){this.view.render(this.state),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=U(e,L(),Y(),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();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=Y(),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 S=(f-1)/2*s+(m-s*f)/2,P=(f-1)/2*r+(p-r*f)/2,H=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:r,top:n.top,left:n.left,once:!0,img:H||i.src||"",afterX:S,afterY:P,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=Y();requestAnimationFrame(()=>{if(this.state.viewer.isOpen&&!(L()===e&&Y()===i)){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}})}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=Y(),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 pt=te;return rt(ft);})();
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);})();
7
7
  SmartPhoto = SmartPhoto.default;
package/lib/smartphoto.js CHANGED
@@ -385,8 +385,9 @@ function makeBound(item, viewer, winWidth, winHeight) {
385
385
  maxY: round(maxY, 6) / item.scale
386
386
  };
387
387
  }
388
+ var FIT_MARGIN = 24;
388
389
  function sizeItems(items, winWidth, winHeight, headerHeight, footerHeight) {
389
- const screenY = winHeight - (headerHeight + footerHeight);
390
+ const screenY = winHeight - (headerHeight + footerHeight) - FIT_MARGIN * 2;
390
391
  items.forEach((item) => {
391
392
  if (!item.loaded) {
392
393
  return;
@@ -1082,12 +1083,13 @@ function createView({ id, options }, handlers, { signal }) {
1082
1083
  refs.caption.focus();
1083
1084
  }
1084
1085
  }
1085
- function render(state) {
1086
+ function render(state, options2) {
1086
1087
  const { viewer } = state;
1087
1088
  refs.count.textContent = `${viewer.currentIndex + 1}/${viewer.total}`;
1088
1089
  refs.slides.forEach((rawSlideRefs, item) => {
1089
1090
  const slideRefs = upgradeIfProcessed(item, rawSlideRefs);
1090
1091
  const isCurrent = item.index === viewer.currentIndex;
1092
+ slideRefs.li.style.transition = options2?.immediate ? "none" : "";
1091
1093
  slideRefs.li.style.transform = `translate(${item.translateX}px,${item.translateY}px)`;
1092
1094
  slideRefs.li.classList.toggle("current", isCurrent);
1093
1095
  if (isCurrent) {
@@ -1346,7 +1348,7 @@ var SmartPhoto = class {
1346
1348
  this.resetTranslateCurrent();
1347
1349
  this.setPosByCurrentIndex();
1348
1350
  this.setSizeByScreen();
1349
- this.commit();
1351
+ this.commit(true);
1350
1352
  };
1351
1353
  this.handleResize = () => {
1352
1354
  if (!this.state.viewer.isOpen || !currentItems(this.state)) {
@@ -1360,7 +1362,7 @@ var SmartPhoto = class {
1360
1362
  this.resetTranslateCurrent();
1361
1363
  this.setPosByCurrentIndex();
1362
1364
  this.setSizeByScreen();
1363
- this.commit();
1365
+ this.commit(true);
1364
1366
  };
1365
1367
  this.handleKeydown = (e) => {
1366
1368
  if (!this.state.viewer.isOpen) {
@@ -1388,21 +1390,22 @@ var SmartPhoto = class {
1388
1390
  this.setPosByCurrentIndex();
1389
1391
  this.setHashByCurrentIndex();
1390
1392
  this.setSizeByScreen();
1391
- this.commit();
1393
+ this.commit(true);
1392
1394
  const prevWidth = getWindowWidth2();
1395
+ const prevHeight = getWindowHeight2();
1393
1396
  const timeout = 500;
1394
1397
  const poll = (time) => {
1395
1398
  this.scheduleTimeout(() => {
1396
1399
  if (!this.state.viewer.isOpen) {
1397
1400
  return;
1398
1401
  }
1399
- if (prevWidth !== getWindowWidth2()) {
1402
+ if (prevWidth !== getWindowWidth2() || prevHeight !== getWindowHeight2()) {
1400
1403
  this.updateViewportHeight();
1401
1404
  this.resetTranslateCurrent();
1402
1405
  this.setPosByCurrentIndex();
1403
1406
  this.setHashByCurrentIndex();
1404
1407
  this.setSizeByScreen();
1405
- this.commit();
1408
+ this.commit(true);
1406
1409
  } else if (time <= timeout) {
1407
1410
  poll(time + 25);
1408
1411
  }
@@ -1812,8 +1815,8 @@ var SmartPhoto = class {
1812
1815
  dialog.style.display = "none";
1813
1816
  }
1814
1817
  }
1815
- commit() {
1816
- this.view.render(this.state);
1818
+ commit(immediate = false) {
1819
+ this.view.render(this.state, { immediate });
1817
1820
  this.view.updatePhotoTransform(this.state);
1818
1821
  this.syncDialog();
1819
1822
  }
@@ -1890,7 +1893,7 @@ var SmartPhoto = class {
1890
1893
  this.resetTranslateCurrent();
1891
1894
  this.setPosByCurrentIndex();
1892
1895
  this.setSizeByScreen();
1893
- this.commit();
1896
+ this.commit(true);
1894
1897
  return;
1895
1898
  }
1896
1899
  this.pendingViewTransitionResync = false;
@@ -2029,7 +2032,7 @@ var SmartPhoto = class {
2029
2032
  this.resetTranslateCurrent();
2030
2033
  this.setPosByCurrentIndex();
2031
2034
  this.setSizeByScreen();
2032
- this.commit();
2035
+ this.commit(true);
2033
2036
  });
2034
2037
  }
2035
2038
  openPhoto(item, trigger) {
@@ -359,8 +359,9 @@ function makeBound(item, viewer, winWidth, winHeight) {
359
359
  maxY: round(maxY, 6) / item.scale
360
360
  };
361
361
  }
362
+ var FIT_MARGIN = 24;
362
363
  function sizeItems(items, winWidth, winHeight, headerHeight, footerHeight) {
363
- const screenY = winHeight - (headerHeight + footerHeight);
364
+ const screenY = winHeight - (headerHeight + footerHeight) - FIT_MARGIN * 2;
364
365
  items.forEach((item) => {
365
366
  if (!item.loaded) {
366
367
  return;
@@ -1056,12 +1057,13 @@ function createView({ id, options }, handlers, { signal }) {
1056
1057
  refs.caption.focus();
1057
1058
  }
1058
1059
  }
1059
- function render(state) {
1060
+ function render(state, options2) {
1060
1061
  const { viewer } = state;
1061
1062
  refs.count.textContent = `${viewer.currentIndex + 1}/${viewer.total}`;
1062
1063
  refs.slides.forEach((rawSlideRefs, item) => {
1063
1064
  const slideRefs = upgradeIfProcessed(item, rawSlideRefs);
1064
1065
  const isCurrent = item.index === viewer.currentIndex;
1066
+ slideRefs.li.style.transition = options2?.immediate ? "none" : "";
1065
1067
  slideRefs.li.style.transform = `translate(${item.translateX}px,${item.translateY}px)`;
1066
1068
  slideRefs.li.classList.toggle("current", isCurrent);
1067
1069
  if (isCurrent) {
@@ -1320,7 +1322,7 @@ var SmartPhoto = class {
1320
1322
  this.resetTranslateCurrent();
1321
1323
  this.setPosByCurrentIndex();
1322
1324
  this.setSizeByScreen();
1323
- this.commit();
1325
+ this.commit(true);
1324
1326
  };
1325
1327
  this.handleResize = () => {
1326
1328
  if (!this.state.viewer.isOpen || !currentItems(this.state)) {
@@ -1334,7 +1336,7 @@ var SmartPhoto = class {
1334
1336
  this.resetTranslateCurrent();
1335
1337
  this.setPosByCurrentIndex();
1336
1338
  this.setSizeByScreen();
1337
- this.commit();
1339
+ this.commit(true);
1338
1340
  };
1339
1341
  this.handleKeydown = (e) => {
1340
1342
  if (!this.state.viewer.isOpen) {
@@ -1362,21 +1364,22 @@ var SmartPhoto = class {
1362
1364
  this.setPosByCurrentIndex();
1363
1365
  this.setHashByCurrentIndex();
1364
1366
  this.setSizeByScreen();
1365
- this.commit();
1367
+ this.commit(true);
1366
1368
  const prevWidth = getWindowWidth2();
1369
+ const prevHeight = getWindowHeight2();
1367
1370
  const timeout = 500;
1368
1371
  const poll = (time) => {
1369
1372
  this.scheduleTimeout(() => {
1370
1373
  if (!this.state.viewer.isOpen) {
1371
1374
  return;
1372
1375
  }
1373
- if (prevWidth !== getWindowWidth2()) {
1376
+ if (prevWidth !== getWindowWidth2() || prevHeight !== getWindowHeight2()) {
1374
1377
  this.updateViewportHeight();
1375
1378
  this.resetTranslateCurrent();
1376
1379
  this.setPosByCurrentIndex();
1377
1380
  this.setHashByCurrentIndex();
1378
1381
  this.setSizeByScreen();
1379
- this.commit();
1382
+ this.commit(true);
1380
1383
  } else if (time <= timeout) {
1381
1384
  poll(time + 25);
1382
1385
  }
@@ -1786,8 +1789,8 @@ var SmartPhoto = class {
1786
1789
  dialog.style.display = "none";
1787
1790
  }
1788
1791
  }
1789
- commit() {
1790
- this.view.render(this.state);
1792
+ commit(immediate = false) {
1793
+ this.view.render(this.state, { immediate });
1791
1794
  this.view.updatePhotoTransform(this.state);
1792
1795
  this.syncDialog();
1793
1796
  }
@@ -1864,7 +1867,7 @@ var SmartPhoto = class {
1864
1867
  this.resetTranslateCurrent();
1865
1868
  this.setPosByCurrentIndex();
1866
1869
  this.setSizeByScreen();
1867
- this.commit();
1870
+ this.commit(true);
1868
1871
  return;
1869
1872
  }
1870
1873
  this.pendingViewTransitionResync = false;
@@ -2003,7 +2006,7 @@ var SmartPhoto = class {
2003
2006
  this.resetTranslateCurrent();
2004
2007
  this.setPosByCurrentIndex();
2005
2008
  this.setSizeByScreen();
2006
- this.commit();
2009
+ this.commit(true);
2007
2010
  });
2008
2011
  }
2009
2012
  openPhoto(item, trigger) {
@@ -31,7 +31,9 @@ export interface ViewHandlers {
31
31
  export interface View {
32
32
  root: HTMLDivElement;
33
33
  refs: ViewRefs;
34
- render(state: State): void;
34
+ render(state: State, options?: {
35
+ immediate?: boolean;
36
+ }): void;
35
37
  syncSlides(items: Item[], state: State): void;
36
38
  updatePhotoTransform(state: State): void;
37
39
  applyViewTransitionLayout(state: State): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smartphoto",
3
- "version": "2.1.16",
3
+ "version": "2.1.17",
4
4
  "description": "smartphoto",
5
5
  "homepage": "https://developer.a-blogcms.jp",
6
6
  "main": "./lib/smartphoto.js",