smartphoto 2.1.9 → 2.1.11

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.9
2
+ * SmartPhoto v2.1.11
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
@@ -55,6 +55,16 @@
55
55
  }
56
56
  return data;
57
57
  };
58
+ var getWindowWidth = () => {
59
+ return document.documentElement.clientWidth;
60
+ };
61
+ var getWindowHeight = () => {
62
+ const visualViewport = window.visualViewport;
63
+ if (visualViewport) {
64
+ return visualViewport.height * visualViewport.scale;
65
+ }
66
+ return document.documentElement.clientHeight;
67
+ };
58
68
  var getViewPos = (element) => {
59
69
  return {
60
70
  left: element.getBoundingClientRect().left,
@@ -412,8 +422,8 @@
412
422
  }
413
423
  function windowSize() {
414
424
  return {
415
- width: document.documentElement.clientWidth,
416
- height: document.documentElement.clientHeight
425
+ width: getWindowWidth(),
426
+ height: getWindowHeight()
417
427
  };
418
428
  }
419
429
  function createGestures({ state, callbacks }, { signal }) {
@@ -1140,16 +1150,8 @@
1140
1150
  }
1141
1151
 
1142
1152
  // src/core/index.ts
1143
- function getWindowWidth() {
1144
- return document.documentElement.clientWidth;
1145
- }
1146
- function getWindowHeight() {
1147
- const visualViewport = window.visualViewport;
1148
- if (visualViewport) {
1149
- return visualViewport.height * visualViewport.scale;
1150
- }
1151
- return document.documentElement.clientHeight;
1152
- }
1153
+ var getWindowWidth2 = getWindowWidth;
1154
+ var getWindowHeight2 = getWindowHeight;
1153
1155
  function isElementArray(source) {
1154
1156
  return source.length > 0 && source[0] instanceof Element;
1155
1157
  }
@@ -1220,7 +1222,7 @@
1220
1222
  this.updateViewportHeight = () => {
1221
1223
  this.view.refs.dialog.style.setProperty(
1222
1224
  "--smartphoto-vh",
1223
- `${getWindowHeight()}px`
1225
+ `${getWindowHeight2()}px`
1224
1226
  );
1225
1227
  };
1226
1228
  // iOS Safari 等ではアドレスバーの表示/非表示に伴う visualViewport の変化が
@@ -1272,11 +1274,11 @@
1272
1274
  this.setHashByCurrentIndex();
1273
1275
  this.setSizeByScreen();
1274
1276
  this.commit();
1275
- const prevWidth = getWindowWidth();
1277
+ const prevWidth = getWindowWidth2();
1276
1278
  const timeout = 500;
1277
1279
  const poll = (time) => {
1278
1280
  this.scheduleTimeout(() => {
1279
- if (prevWidth !== getWindowWidth()) {
1281
+ if (prevWidth !== getWindowWidth2()) {
1280
1282
  this.updateViewportHeight();
1281
1283
  this.resetTranslateCurrent();
1282
1284
  this.setPosByCurrentIndex();
@@ -1417,8 +1419,8 @@
1417
1419
  this.state.viewer.hideUi = true;
1418
1420
  this.state.viewer.scaleSize = scaleBorder(
1419
1421
  item,
1420
- getWindowWidth(),
1421
- getWindowHeight(),
1422
+ getWindowWidth2(),
1423
+ getWindowHeight2(),
1422
1424
  this.isSmartPhoneFlag
1423
1425
  );
1424
1426
  if (this.state.viewer.scaleSize <= 1) {
@@ -1508,7 +1510,7 @@
1508
1510
  element,
1509
1511
  this.state.options,
1510
1512
  index,
1511
- getWindowWidth()
1513
+ getWindowWidth2()
1512
1514
  );
1513
1515
  addItemToGroup(this.state, item);
1514
1516
  this.loadAllFired.delete(groupId);
@@ -1519,7 +1521,7 @@
1519
1521
  var _a, _b;
1520
1522
  const groupId = groupIdFromSlide(slide);
1521
1523
  const index = (_b = (_a = this.state.groups.get(groupId)) == null ? void 0 : _a.length) != null ? _b : 0;
1522
- const item = itemFromSlide(slide, index, getWindowWidth());
1524
+ const item = itemFromSlide(slide, index, getWindowWidth2());
1523
1525
  addItemToGroup(this.state, item);
1524
1526
  this.loadAllFired.delete(groupId);
1525
1527
  return item;
@@ -1575,7 +1577,7 @@
1575
1577
  el,
1576
1578
  this.state.options,
1577
1579
  index,
1578
- getWindowWidth()
1580
+ getWindowWidth2()
1579
1581
  );
1580
1582
  this.itemsByElement.set(el, item);
1581
1583
  return item;
@@ -1585,7 +1587,7 @@
1585
1587
  this.itemsByElement.delete(it.element);
1586
1588
  }
1587
1589
  });
1588
- resetTranslate(rebuilt, getWindowWidth());
1590
+ resetTranslate(rebuilt, getWindowWidth2());
1589
1591
  this.state.groups.set(groupId, rebuilt);
1590
1592
  if (changed) {
1591
1593
  this.loadAllFired.delete(groupId);
@@ -1637,15 +1639,15 @@
1637
1639
  }
1638
1640
  sizeItems(
1639
1641
  items,
1640
- getWindowWidth(),
1641
- getWindowHeight(),
1642
+ getWindowWidth2(),
1643
+ getWindowHeight2(),
1642
1644
  this.state.options.headerHeight,
1643
1645
  this.state.options.footerHeight
1644
1646
  );
1645
1647
  }
1646
1648
  // resize/orientationchange ハンドラは呼び出し前に currentItems の存在を確認済み
1647
1649
  resetTranslateCurrent() {
1648
- resetTranslate(currentItems(this.state), getWindowWidth());
1650
+ resetTranslate(currentItems(this.state), getWindowWidth2());
1649
1651
  }
1650
1652
  currentImgElement() {
1651
1653
  for (const [item, slideRefs] of this.view.refs.slides) {
@@ -1693,8 +1695,8 @@
1693
1695
  this.state.viewer.hideUi = true;
1694
1696
  this.state.viewer.scaleSize = scaleBorder(
1695
1697
  item,
1696
- getWindowWidth(),
1697
- getWindowHeight(),
1698
+ getWindowWidth2(),
1699
+ getWindowHeight2(),
1698
1700
  this.isSmartPhoneFlag
1699
1701
  );
1700
1702
  }
@@ -1747,8 +1749,8 @@
1747
1749
  const pos = getViewPos(img);
1748
1750
  const width = img.offsetWidth;
1749
1751
  const height = img.offsetHeight;
1750
- const toX = getWindowWidth();
1751
- const toY = getWindowHeight();
1752
+ const toX = getWindowWidth2();
1753
+ const toY = getWindowHeight2();
1752
1754
  const screenY = toY - this.state.options.headerHeight - this.state.options.footerHeight;
1753
1755
  let scale = 1;
1754
1756
  if (this.state.options.resizeStyle === "fill" && this.isSmartPhoneFlag) {
@@ -1835,13 +1837,13 @@
1835
1837
  // dialog が開いてスクロールバーが消えた後の幅とズレる。次の描画フレームで
1836
1838
  // 開いた後の正しいサイズを使って再計算し、必要なら再描画する
1837
1839
  resyncSizeAfterOpen() {
1838
- const winWidthBefore = getWindowWidth();
1839
- const winHeightBefore = getWindowHeight();
1840
+ const winWidthBefore = getWindowWidth2();
1841
+ const winHeightBefore = getWindowHeight2();
1840
1842
  requestAnimationFrame(() => {
1841
1843
  if (!this.state.viewer.isOpen) {
1842
1844
  return;
1843
1845
  }
1844
- if (getWindowWidth() === winWidthBefore && getWindowHeight() === winHeightBefore) {
1846
+ if (getWindowWidth2() === winWidthBefore && getWindowHeight2() === winHeightBefore) {
1845
1847
  return;
1846
1848
  }
1847
1849
  this.resetTranslateCurrent();
@@ -1871,7 +1873,7 @@
1871
1873
  return new Promise((resolve) => {
1872
1874
  const dialog = this.view.refs.dialog;
1873
1875
  const img = this.currentImgElement();
1874
- const height = getWindowHeight();
1876
+ const height = getWindowHeight2();
1875
1877
  const applied = dir === "top" ? `translateY(-${height}px)` : `translateY(${height}px)`;
1876
1878
  const finish = () => {
1877
1879
  if (this.finishHideEffect !== finish) {
@@ -1934,6 +1936,9 @@
1934
1936
  }
1935
1937
  if (promises.length) {
1936
1938
  Promise.all(promises).then(() => {
1939
+ if (!this.state.viewer.isOpen) {
1940
+ return;
1941
+ }
1937
1942
  this.initPhoto();
1938
1943
  this.commit();
1939
1944
  });
@@ -1963,6 +1968,9 @@
1963
1968
  this.loadNeighborItems();
1964
1969
  if (item && !item.loaded) {
1965
1970
  this.loadItem(item).then(() => {
1971
+ if (!this.state.viewer.isOpen) {
1972
+ return;
1973
+ }
1966
1974
  this.initPhoto();
1967
1975
  this.commit();
1968
1976
  });
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * SmartPhoto v2.1.9
2
+ * SmartPhoto v2.1.11
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
6
- "use strict";(()=>{var K=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};function Pe(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let r=e[o];if(r){for(let s in r)if(Object.hasOwn(r,s)){let n=r[s];n&&typeof n=="object"?t[s]=Pe((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var Se=Pe,xe=(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)},Ie=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),r=o[0],s=o.length>1?o.slice(1).join("="):r;e[r]=decodeURIComponent(s)}return e},Le=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var be=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},Fe=.179,Re=([t,e,i])=>{let[o,r,s]=[t,e,i].map(n=>{let u=n/255;return u<=.03928?u/12.92:((u+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*s},Ce=t=>{let e=t.trim(),i=be(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=be(getComputedStyle(o).color),document.body.removeChild(o)}return i&&Re(i)>Fe?"#000":"#fff"};var $e={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,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:450};function Te(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Te(i)}),Object.freeze(t)}function Ae(t){return{options:Te(Se({},$e,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 q(t){return t.getAttribute("data-group")||"nogroup"}function de(t){return t.group||"nogroup"}function ce(t,e,i,o){let r=q(t),s=t.getAttribute("href"),n=t.querySelector("img"),u=s;n&&(n.getAttribute(e.lazyAttribute)?u=n.getAttribute(e.lazyAttribute):n.currentSrc?u=n.currentSrc:u=n.src);let p="";n!=null&&n.getAttribute("alt")?p=n.getAttribute("alt"):t.getAttribute("data-caption")?p=t.getAttribute("data-caption"):p=s!=null?s:"";let d=t.getAttribute("data-id");return{src:s,thumb:u,caption:t.getAttribute("data-caption"),alt:p,groupId:r,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:d||i,loaded:!1,processed:!1,element:t}}function Me(t,e,i){var d,v,y,P,S;let o=de(t),r=t.src,s=(d=t.thumb)!=null?d:r,n=(v=t.caption)!=null?v:null,u=(P=(y=t.alt)!=null?y:n)!=null?P:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:u,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:(S=t.id)!=null?S:e,loaded:p,processed:!1,element:null}}function me(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 A(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function z(t){var i;let e=A(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function pe(t){let e=A(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,r=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),r!==-1&&(t.viewer.prev=r,t.viewer.showPrevArrow=!0)}function fe(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function Z(t,e){let i=10**e;return Math.round(t*i)/i}function Q(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function He(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,u,p,d;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(d=(o-s)/2,u=-1*d):(d=(s-o)/2,u=-1*d),{minX:Z(n,6)*e.scaleSize,minY:Z(u,6)*e.scaleSize,maxX:Z(p,6)*e.scaleSize,maxY:Z(d,6)*e.scaleSize}}function ze(t,e,i,o,r){let s=i-(o+r);t.forEach(n=>{n.loaded&&(n.processed=!0,n.scale=s/n.height,n.height<s&&(n.scale=1),n.x=(n.scale-1)/2*n.width+(e-n.width*n.scale)/2,n.y=(n.scale-1)/2*n.height+(i-n.height*n.scale)/2,n.width*n.scale>e&&(n.scale=e/n.width,n.x=(n.scale-1)/2*n.width))})}function Oe(t){let e=z(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function De(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(r=>{e.group===r.groupId&&e.photo===r.id&&(i=r)})}),i}function ve(t,e){let i=10**e;return Math.round(t*i)/i}function $(t){return{x:t.pageX,y:t.pageY}}function Ne(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var We=10;function Ue(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ve(){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}function Be({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,u=null,p=null,d=null,v=0,y=!1,P=null,S=null,O=0,D=0,H=!1,Y=0,x=null,C=0,N=0;function c(){return K()}function W(a){let{width:h,height:E}=Ve();return He(a,t.viewer,h,E)}function U(a){let{width:h,height:E}=Ve();return Q(a,h,E,c())}function te(a,h){let E=z(t),g=W(E);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 ie=setInterval(()=>{if(H||s||y||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=C,t.viewer.photoPosY+=N;let a=z(t);if(!a)return;let h=W(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,C*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,C*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,N*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,N*=-.2);let E=Ue(C,N),g=E.force-t.options.registance;Math.abs(g)<.5||(C=Math.cos(E.theta)*g,N=Math.sin(E.theta)*g,e.onPhotoDragMove())},t.options.forceInterval);function V(a,h){(a>5||a<-5)&&(C+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(N+=h*.05)}function J(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||H||s||y||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?V(a.gamma,a.beta):h===90?V(a.beta,a.gamma):h===-90?V(-a.beta,-a.gamma):h===180&&V(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",J,{signal:i});function oe(){H=!0,s=!1,y=!1;let a=Array.from(o.values());Y=Ne(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function re(a){let h=$(a);s=!0,n=!0,u=h,p=h,v=Date.now()}function ne(a){y=!0;let h=$(a);S=h,P=h}function se(a){var h,E;try{(E=(h=a.currentTarget).setPointerCapture)==null||E.call(h,a.pointerId)}catch(g){}if(o.set(a.pointerId,$(a)),o.size>1){oe();return}if(t.viewer.scale){ne(a);return}re(a)}function ae(){x===null&&(x=requestAnimationFrame(()=>{x=null,e.onGestureMove()}))}function le(){x!==null&&(cancelAnimationFrame(x),x=null,e.onGestureMove())}function m(){let a=Array.from(o.values()),h=Ne(a[0],a[1]),E=(h-Y)/100,g=t.viewer.scaleSize,L=t.viewer.photoPosX,T=t.viewer.photoPosY;t.viewer.scaleSize+=ve(E,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<g&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-g)*L,t.viewer.photoPosY=(1+t.viewer.scaleSize-g)*T);let X=z(t);if(X){let he=U(X);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>he}Y=h,ae()}function l(a){let h=$(a),E=h.x-p.x,g=h.y-u.y;n&&(e.onSwipeStart(),n=!1,d=Math.abs(E)>Math.abs(g)?"horizontal":"vertical"),d==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=g,p=h,e.onSwipeMove()}function b(a){let h=$(a),E=h.x-S.x,g=h.y-S.y,L=ve(t.viewer.scaleSize*E,6),T=ve(t.viewer.scaleSize*g,6);t.viewer.photoPosX+=L,O=L,t.viewer.photoPosY+=T,D=T,S=h,e.onPhotoDragMove()}function w(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,$(a)),H){m();return}if(y){b(a);return}l(a)}}function f(){H=!1,le();let a=z(t);if(!a)return;let h=U(a);t.viewer.scaleSize>h||(t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scale=!1,t.viewer.scaleSize=1,t.viewer.hideUi=!1,e.onGestureEnd())}function I(){var Ee;s=!1;let a=u,h=p,E=Date.now(),g=r-E,L=h.x-a.x,T=h.y-a.y,X=L===0&&T===0;if(!c()&&X){e.onTap();return}if(Math.abs(g)<=500&&X){e.onTap();return}r=E;let he=(Ee=A(t))!=null?Ee:[];if(d==="horizontal"){let R="stay",ke=Math.max(E-v,1),ye=Math.abs(L)>=We&&Math.abs(L)/ke>=t.options.swipeVelocity;(L>=t.options.swipeOffset||ye&&L>0)&&t.viewer.currentIndex!==0?R="prev":(L<=-t.options.swipeOffset||ye&&L<0)&&t.viewer.currentIndex!==he.length-1&&(R="next"),e.onSwipeEnd(R)}else{let R="stay";t.options.swipeBottomToClose&&T>=t.options.swipeOffset?R="close-bottom":t.options.swipeTopToClose&&T<=-t.options.swipeOffset&&(R="close-top"),e.onSwipeEnd(R)}}function F(){y=!1;let a=S,h=P;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let E=z(t);if(!E){e.onPhotoDragEnd(null);return}let g=W(E),L=t.options.swipeOffset*t.viewer.scaleSize,T=0,X=0;if(t.viewer.photoPosX>g.maxX?T=-1:t.viewer.photoPosX<g.minX&&(T=1),t.viewer.photoPosY>g.maxY?X=-1:t.viewer.photoPosY<g.minY&&(X=1),t.viewer.photoPosX-g.maxX>L&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(g.minX-t.viewer.photoPosX>L&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}T===0&&X===0?(C=O/5,N=D/5):te(T,X),e.onPhotoDragEnd(null)}function j(a){if(o.delete(a.pointerId),H){o.size<2&&f();return}if(y){F();return}s&&I()}function B(...a){for(let h of a)h.addEventListener("pointerdown",se,{signal:i}),h.addEventListener("pointermove",w,{signal:i}),h.addEventListener("pointerup",j,{signal:i}),h.addEventListener("pointercancel",j,{signal:i})}function G(){clearInterval(ie),x!==null&&(cancelAnimationFrame(x),x=null)}return{attach:B,detach:G}}function ee(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function we(){let t=document.createElement("button");return t.type="button",t}function je(t){return t.replace(/"/g,'\\"')}function Xe({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let u=document.createElement("dialog");u.className=r.smartPhoto,u.setAttribute("aria-labelledby",`smartphoto-${t}-title`),u.style.display="none",u.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let d=document.createElement("div");d.className=r.smartPhotoInner;let v=document.createElement("div");v.className=r.smartPhotoHeader;let y=document.createElement("span");y.className=r.smartPhotoCount;let P=document.createElement("h1");P.id=`smartphoto-${t}-title`,P.className=r.smartPhotoCaption,P.setAttribute("tabindex","-1");let S=document.createElement("button");S.className=r.smartPhotoDismiss,S.appendChild(ee(s.closeDialog)),S.addEventListener("click",()=>i.onDismiss(),{signal:o}),v.append(y,P,S);let O=document.createElement("div");O.className=r.smartPhotoContent,O.addEventListener("click",m=>{m.target===O&&i.onBackdropClick()},{signal:o});let D=document.createElement("ul");D.className=r.smartPhotoList,D.setAttribute("role","region"),D.setAttribute("aria-roledescription","carousel"),D.setAttribute("aria-label",s.carouselLabel),D.setAttribute("aria-live","polite"),D.setAttribute("aria-atomic","false"),d.append(v,O,D);let H=null,Y=null,x=null;if(e.arrows){H=document.createElement("ul"),H.className=r.smartPhotoArrows,Y=document.createElement("li"),Y.className=r.smartPhotoArrowLeft;let m=we();m.appendChild(ee(s.gotoPrevImage)),m.addEventListener("click",()=>i.onPrev(),{signal:o}),Y.appendChild(m),x=document.createElement("li"),x.className=r.smartPhotoArrowRight;let l=we();l.appendChild(ee(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),x.appendChild(l),H.append(Y,x),d.appendChild(H)}let C=null,N=null;e.nav&&(C=document.createElement("nav"),C.className=r.smartPhotoNav,C.setAttribute("aria-label","Choose slide to display"),N=document.createElement("ul"),C.appendChild(N),d.appendChild(C)),p.appendChild(d),u.appendChild(p),n.appendChild(u);let c={dialog:u,count:y,caption:P,dismiss:S,content:O,list:D,arrows:H,arrowLeft:Y,arrowRight:x,nav:C,navList:N,slides:new Map,imgClone:null};function W(){let m=document.createElement("div");m.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,m.appendChild(l),m}function U(m){var w,f;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let b=document.createElement("img");return b.className=r.smartPhotoImg,b.src=(w=m.src)!=null?w:"",b.alt=(f=m.alt)!=null?f:"",b.addEventListener("dragstart",I=>I.preventDefault(),{signal:o}),l.appendChild(b),{imgWrap:l,img:b}}function te(m,l){var b;c.list.replaceChildren(),(b=c.navList)==null||b.replaceChildren(),c.slides=new Map,m.forEach(w=>{var F,j;let f=document.createElement("li");f.setAttribute("role","group"),f.setAttribute("aria-roledescription","slide"),f.setAttribute("aria-label",`${w.index+1} of ${m.length}`);let I={li:f,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(w.processed){let{imgWrap:B,img:G}=U(w);f.appendChild(B),I.imgWrap=B,I.img=G}else{let B=W();f.appendChild(B),I.loaderWrap=B}if(c.list.appendChild(f),c.slides.set(w,I),c.navList){let B=document.createElement("li"),G=we();G.style.backgroundImage=`url("${je((F=w.thumb)!=null?F:"")}")`;let a=w.index;G.addEventListener("click",()=>i.onNavigate(a),{signal:o}),G.appendChild(ee(`go to ${(j=w.caption)!=null?j:""}`)),B.appendChild(G),c.navList.appendChild(B),I.navLink=G}}),J(l)}function ie(m,l){var f;if(l.imgWrap||!m.processed)return l;let{imgWrap:b,img:w}=U(m);return(f=l.loaderWrap)==null||f.replaceWith(b),l.loaderWrap=null,l.imgWrap=b,l.img=w,l}function V(m){m&&document.activeElement&&m.contains(document.activeElement)&&c.caption.focus()}function J(m){let{viewer:l}=m;c.count.textContent=`${l.currentIndex+1}/${l.total}`,c.slides.forEach((b,w)=>{var F;let f=ie(w,b),I=w.index===l.currentIndex;f.li.style.transform=`translate(${w.translateX}px,${w.translateY}px)`,f.li.classList.toggle("current",I),I?f.li.removeAttribute("aria-hidden"):f.li.setAttribute("aria-hidden","true"),I&&(c.caption.textContent=(F=w.caption)!=null?F:""),f.imgWrap&&f.img&&(f.imgWrap.style.transform=`translate(${w.x}px,${w.y}px) scale(${w.scale})`,f.img.style.width=`${w.width}px`,f.img.classList.toggle("active",l.appear),f.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),f.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),f.navLink&&(f.navLink.classList.toggle("current",I),I?f.navLink.setAttribute("aria-current","true"):f.navLink.removeAttribute("aria-current"))}),c.arrowLeft&&(l.showPrevArrow?c.arrowLeft.removeAttribute("aria-hidden"):(V(c.arrowLeft),c.arrowLeft.setAttribute("aria-hidden","true"))),c.arrowRight&&(l.showNextArrow?c.arrowRight.removeAttribute("aria-hidden"):(V(c.arrowRight),c.arrowRight.setAttribute("aria-hidden","true"))),c.arrows&&(l.hideUi&&V(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.nav&&(l.hideUi&&V(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function oe(m){for(let[l,b]of c.slides)if(l.index===m.viewer.currentIndex)return b;return null}function re(m){let{viewer:l}=m,b=oe(m),w=b==null?void 0:b.img;w&&(w.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,w.classList.toggle(r.smartPhotoImgOnMove,l.scale),w.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),c.nav&&(l.hideUi&&V(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.arrows&&(l.hideUi&&V(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ne(m){let{viewer:l}=m;c.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,c.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function se(m){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=m.img,l.style.width=`${m.width}px`,l.style.height=`${m.height}px`,l.style.transform=`translate(${m.left}px,${m.top}px) scale(1)`,p.appendChild(l),c.imgClone=l}function ae(){var m;(m=c.imgClone)==null||m.remove(),c.imgClone=null}function le(){n.remove()}return{root:n,refs:c,render:J,syncSlides:te,updatePhotoTransform:re,updateListTransform:ne,showAppearEffect:se,removeAppearEffect:ae,destroy:le}}function M(){return document.documentElement.clientWidth}function k(){let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight}function qe(t){return t.length>0&&t[0]instanceof Element}function Qe(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function Ye(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var _=class{constructor(e,i){this.id=Qe();this.abortController=new AbortController;this.isSmartPhoneFlag=K();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;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=q(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let r=this.itemsByElement.get(o);r&&this.openPhoto(r,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${k()}px`)};this.handleVisualViewportResize=()=>{this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!A(this.state))&&(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit())};this.handleResize=()=>{A(this.state)&&(this.updateViewportHeight(),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(!A(this.state))return;this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=M(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==M()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25)},25)};o(0)};this.rootSelector=typeof e=="string"?e:null,this.state=Ae(i!=null?i:{}),this.view=Xe({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Be({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,r=s=>i.call(o,s);o.addEventListener(e,r,{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){this.state.viewer.currentIndex=Number.parseInt(String(e),10),this.state.viewer.currentIndex||(this.state.viewer.currentIndex=0),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=Ye();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=z(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=Q(e,M(),k(),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.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin")},300)))}zoomOutPhoto(){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.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var p,d,v;let o=(p=i.group)!=null?p:this.state.viewer.currentGroup;if(o===null)return;let r=this.state.groups.get(o);if(!(r!=null&&r.length))return;let s=typeof e=="number"?r[e]:r.find(y=>y.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,u=(v=(d=i.trigger)!=null?d:s.element)!=null?v:n;this.openPhoto(s,u)}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)&&!qe(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,n;let i=q(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=ce(e,this.state.options,o,M());return me(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=de(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Me(e,o,M());return me(this.state,r),this.loadAllFired.delete(i),r}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(d=>q(d)===e),o=new Set(i),r=(p=this.state.groups.get(e))!=null?p:[],s=new Map;r.forEach(d=>{d.element&&s.set(d.element,d)});let n=i.length!==r.length,u=i.map((d,v)=>{let y=s.get(d);if(y)return y.index!==v&&(n=!0,y.index=v),y;n=!0;let P=ce(d,this.state.options,v,M());return this.itemsByElement.set(d,P),P});return r.forEach(d=>{d.element&&!o.has(d.element)&&this.itemsByElement.delete(d.element)}),fe(u,M()),this.state.groups.set(e,u),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=A(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=Ye();this.setHash(Oe(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?De(this.state,Ie(e)):null}setPosByCurrentIndex(){let e=z(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=A(this.state);e&&ze(e,M(),k(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){fe(A(this.state),M())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;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.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=A(this.state);if(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(),pe(this.state),this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag){let o=z(this.state);this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=Q(o,M(),k(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}openPhotoWithViewTransition(e){var n,u;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(n=e==null?void 0:e.querySelector("img"))!=null?n:null;o&&(o.style.viewTransitionName=i);let r=()=>{o&&(o.style.viewTransitionName="");let p=this.currentImgElement();p&&(p.style.viewTransitionName="")},s=(u=document.startViewTransition)==null?void 0:u.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i});s==null||s.ready.catch(()=>{r()}),s==null||s.finished.then(r,r)}addAppearEffect(e,i){var O;let o=(O=e==null?void 0:e.querySelector("img"))!=null?O:null;if(!o){this.state.viewer.appear=!0;return}let r=Le(o),s=o.offsetWidth,n=o.offsetHeight,u=M(),p=k(),d=p-this.state.options.headerHeight-this.state.options.footerHeight,v=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?v=p/n:v=u/s:(s>=n?i.height<d?v=i.width/s:v=d/n:i.height<d?v=i.height/n:v=d/n,s*v>u&&(v=u/s));let y=(v-1)/2*s+(u-s*v)/2,P=(v-1)/2*n+(p-n*v)/2,S=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:S||i.src||"",afterX:y,afterY:P,scale:v}}runAppearEffect(e){this.view.showAppearEffect(e);let i=this.view.refs.imgClone;return new Promise(o=>{let r=()=>{i.removeEventListener("transitionend",r,!0),o()};i.addEventListener("transitionend",r,!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=M(),i=k();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(M()===e&&k()===i||(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.view.render(this.state)))})}openPhoto(e,i){let o=this.rootSelector?this.resyncGroupFromDom(e.groupId):!1;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=>{let o=this.view.refs.dialog,r=this.currentImgElement(),s=k(),n=e==="top"?`translateY(-${s}px)`:`translateY(${s}px)`,u=()=>{this.finishHideEffect===u&&(this.finishHideEffect=null,o.removeEventListener("transitionend",u,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=u,r&&(r.style.transform=n),o.addEventListener("transitionend",u,!0),this.scheduleTimeout(u,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;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=(r=e.src)!=null?r:""})}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=A(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).then(()=>{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=z(this.state);this.state.viewer.onMove=!1,pe(this.state),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.initPhoto(),this.commit()})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(r=>r!==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",Ce(o))}fireEvent(e){xe(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:()=>this.zoomPhoto(),onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},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 Ge=_;var ge=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new Ge(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],ge);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&ge(e)}var at=ge;})();
6
+ "use strict";(()=>{var K=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};function xe(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let r=e[o];if(r){for(let s in r)if(Object.hasOwn(r,s)){let n=r[s];n&&typeof n=="object"?t[s]=xe((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var Ie=xe,Le=(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)},Ce=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),r=o[0],s=o.length>1?o.slice(1).join("="):r;e[r]=decodeURIComponent(s)}return e},Z=()=>document.documentElement.clientWidth,ee=()=>{let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight},Te=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var Se=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},Re=.179,$e=([t,e,i])=>{let[o,r,s]=[t,e,i].map(n=>{let u=n/255;return u<=.03928?u/12.92:((u+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*s},Ae=t=>{let e=t.trim(),i=Se(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=Se(getComputedStyle(o).color),document.body.removeChild(o)}return i&&$e(i)>Re?"#000":"#fff"};var Ue={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,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:450};function Me(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Me(i)}),Object.freeze(t)}function He(t){return{options:Me(Ie({},Ue,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 q(t){return t.getAttribute("data-group")||"nogroup"}function me(t){return t.group||"nogroup"}function pe(t,e,i,o){let r=q(t),s=t.getAttribute("href"),n=t.querySelector("img"),u=s;n&&(n.getAttribute(e.lazyAttribute)?u=n.getAttribute(e.lazyAttribute):n.currentSrc?u=n.currentSrc:u=n.src);let p="";n!=null&&n.getAttribute("alt")?p=n.getAttribute("alt"):t.getAttribute("data-caption")?p=t.getAttribute("data-caption"):p=s!=null?s:"";let d=t.getAttribute("data-id");return{src:s,thumb:u,caption:t.getAttribute("data-caption"),alt:p,groupId:r,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:d||i,loaded:!1,processed:!1,element:t}}function ze(t,e,i){var d,v,y,P,S;let o=me(t),r=t.src,s=(d=t.thumb)!=null?d:r,n=(v=t.caption)!=null?v:null,u=(P=(y=t.alt)!=null?y:n)!=null?P:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:u,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:(S=t.id)!=null?S:e,loaded:p,processed:!1,element:null}}function fe(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 A(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function z(t){var i;let e=A(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function ve(t){let e=A(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,r=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),r!==-1&&(t.viewer.prev=r,t.viewer.showPrevArrow=!0)}function we(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function te(t,e){let i=10**e;return Math.round(t*i)/i}function Q(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Oe(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,u,p,d;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(d=(o-s)/2,u=-1*d):(d=(s-o)/2,u=-1*d),{minX:te(n,6)*e.scaleSize,minY:te(u,6)*e.scaleSize,maxX:te(p,6)*e.scaleSize,maxY:te(d,6)*e.scaleSize}}function De(t,e,i,o,r){let s=i-(o+r);t.forEach(n=>{n.loaded&&(n.processed=!0,n.scale=s/n.height,n.height<s&&(n.scale=1),n.x=(n.scale-1)/2*n.width+(e-n.width*n.scale)/2,n.y=(n.scale-1)/2*n.height+(i-n.height*n.scale)/2,n.width*n.scale>e&&(n.scale=e/n.width,n.x=(n.scale-1)/2*n.width))})}function Ne(t){let e=z(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function Ve(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(r=>{e.group===r.groupId&&e.photo===r.id&&(i=r)})}),i}function ge(t,e){let i=10**e;return Math.round(t*i)/i}function R(t){return{x:t.pageX,y:t.pageY}}function Be(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var je=10;function qe(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Xe(){return{width:Z(),height:ee()}}function Ye({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,u=null,p=null,d=null,v=0,y=!1,P=null,S=null,O=0,D=0,H=!1,Y=0,x=null,C=0,N=0;function c(){return K()}function $(a){let{width:h,height:E}=Xe();return Oe(a,t.viewer,h,E)}function U(a){let{width:h,height:E}=Xe();return Q(a,h,E,c())}function oe(a,h){let E=z(t),g=$(E);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 re=setInterval(()=>{if(H||s||y||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=C,t.viewer.photoPosY+=N;let a=z(t);if(!a)return;let h=$(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,C*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,C*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,N*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,N*=-.2);let E=qe(C,N),g=E.force-t.options.registance;Math.abs(g)<.5||(C=Math.cos(E.theta)*g,N=Math.sin(E.theta)*g,e.onPhotoDragMove())},t.options.forceInterval);function V(a,h){(a>5||a<-5)&&(C+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(N+=h*.05)}function J(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||H||s||y||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?V(a.gamma,a.beta):h===90?V(a.beta,a.gamma):h===-90?V(-a.beta,-a.gamma):h===180&&V(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",J,{signal:i});function ne(){H=!0,s=!1,y=!1;let a=Array.from(o.values());Y=Be(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function se(a){let h=R(a);s=!0,n=!0,u=h,p=h,v=Date.now()}function ae(a){y=!0;let h=R(a);S=h,P=h}function le(a){var h,E;try{(E=(h=a.currentTarget).setPointerCapture)==null||E.call(h,a.pointerId)}catch(g){}if(o.set(a.pointerId,R(a)),o.size>1){ne();return}if(t.viewer.scale){ae(a);return}se(a)}function he(){x===null&&(x=requestAnimationFrame(()=>{x=null,e.onGestureMove()}))}function ue(){x!==null&&(cancelAnimationFrame(x),x=null,e.onGestureMove())}function m(){let a=Array.from(o.values()),h=Be(a[0],a[1]),E=(h-Y)/100,g=t.viewer.scaleSize,L=t.viewer.photoPosX,T=t.viewer.photoPosY;t.viewer.scaleSize+=ge(E,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<g&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-g)*L,t.viewer.photoPosY=(1+t.viewer.scaleSize-g)*T);let X=z(t);if(X){let de=U(X);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>de}Y=h,he()}function l(a){let h=R(a),E=h.x-p.x,g=h.y-u.y;n&&(e.onSwipeStart(),n=!1,d=Math.abs(E)>Math.abs(g)?"horizontal":"vertical"),d==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=g,p=h,e.onSwipeMove()}function b(a){let h=R(a),E=h.x-S.x,g=h.y-S.y,L=ge(t.viewer.scaleSize*E,6),T=ge(t.viewer.scaleSize*g,6);t.viewer.photoPosX+=L,O=L,t.viewer.photoPosY+=T,D=T,S=h,e.onPhotoDragMove()}function w(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,R(a)),H){m();return}if(y){b(a);return}l(a)}}function f(){H=!1,ue();let a=z(t);if(!a)return;let h=U(a);t.viewer.scaleSize>h||(t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scale=!1,t.viewer.scaleSize=1,t.viewer.hideUi=!1,e.onGestureEnd())}function I(){var be;s=!1;let a=u,h=p,E=Date.now(),g=r-E,L=h.x-a.x,T=h.y-a.y,X=L===0&&T===0;if(!c()&&X){e.onTap();return}if(Math.abs(g)<=500&&X){e.onTap();return}r=E;let de=(be=A(t))!=null?be:[];if(d==="horizontal"){let F="stay",Fe=Math.max(E-v,1),Pe=Math.abs(L)>=je&&Math.abs(L)/Fe>=t.options.swipeVelocity;(L>=t.options.swipeOffset||Pe&&L>0)&&t.viewer.currentIndex!==0?F="prev":(L<=-t.options.swipeOffset||Pe&&L<0)&&t.viewer.currentIndex!==de.length-1&&(F="next"),e.onSwipeEnd(F)}else{let F="stay";t.options.swipeBottomToClose&&T>=t.options.swipeOffset?F="close-bottom":t.options.swipeTopToClose&&T<=-t.options.swipeOffset&&(F="close-top"),e.onSwipeEnd(F)}}function W(){y=!1;let a=S,h=P;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let E=z(t);if(!E){e.onPhotoDragEnd(null);return}let g=$(E),L=t.options.swipeOffset*t.viewer.scaleSize,T=0,X=0;if(t.viewer.photoPosX>g.maxX?T=-1:t.viewer.photoPosX<g.minX&&(T=1),t.viewer.photoPosY>g.maxY?X=-1:t.viewer.photoPosY<g.minY&&(X=1),t.viewer.photoPosX-g.maxX>L&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(g.minX-t.viewer.photoPosX>L&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}T===0&&X===0?(C=O/5,N=D/5):oe(T,X),e.onPhotoDragEnd(null)}function j(a){if(o.delete(a.pointerId),H){o.size<2&&f();return}if(y){W();return}s&&I()}function B(...a){for(let h of a)h.addEventListener("pointerdown",le,{signal:i}),h.addEventListener("pointermove",w,{signal:i}),h.addEventListener("pointerup",j,{signal:i}),h.addEventListener("pointercancel",j,{signal:i})}function G(){clearInterval(re),x!==null&&(cancelAnimationFrame(x),x=null)}return{attach:B,detach:G}}function ie(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function Ee(){let t=document.createElement("button");return t.type="button",t}function Qe(t){return t.replace(/"/g,'\\"')}function Ge({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let u=document.createElement("dialog");u.className=r.smartPhoto,u.setAttribute("aria-labelledby",`smartphoto-${t}-title`),u.style.display="none",u.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let d=document.createElement("div");d.className=r.smartPhotoInner;let v=document.createElement("div");v.className=r.smartPhotoHeader;let y=document.createElement("span");y.className=r.smartPhotoCount;let P=document.createElement("h1");P.id=`smartphoto-${t}-title`,P.className=r.smartPhotoCaption,P.setAttribute("tabindex","-1");let S=document.createElement("button");S.className=r.smartPhotoDismiss,S.appendChild(ie(s.closeDialog)),S.addEventListener("click",()=>i.onDismiss(),{signal:o}),v.append(y,P,S);let O=document.createElement("div");O.className=r.smartPhotoContent,O.addEventListener("click",m=>{m.target===O&&i.onBackdropClick()},{signal:o});let D=document.createElement("ul");D.className=r.smartPhotoList,D.setAttribute("role","region"),D.setAttribute("aria-roledescription","carousel"),D.setAttribute("aria-label",s.carouselLabel),D.setAttribute("aria-live","polite"),D.setAttribute("aria-atomic","false"),d.append(v,O,D);let H=null,Y=null,x=null;if(e.arrows){H=document.createElement("ul"),H.className=r.smartPhotoArrows,Y=document.createElement("li"),Y.className=r.smartPhotoArrowLeft;let m=Ee();m.appendChild(ie(s.gotoPrevImage)),m.addEventListener("click",()=>i.onPrev(),{signal:o}),Y.appendChild(m),x=document.createElement("li"),x.className=r.smartPhotoArrowRight;let l=Ee();l.appendChild(ie(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),x.appendChild(l),H.append(Y,x),d.appendChild(H)}let C=null,N=null;e.nav&&(C=document.createElement("nav"),C.className=r.smartPhotoNav,C.setAttribute("aria-label","Choose slide to display"),N=document.createElement("ul"),C.appendChild(N),d.appendChild(C)),p.appendChild(d),u.appendChild(p),n.appendChild(u);let c={dialog:u,count:y,caption:P,dismiss:S,content:O,list:D,arrows:H,arrowLeft:Y,arrowRight:x,nav:C,navList:N,slides:new Map,imgClone:null};function $(){let m=document.createElement("div");m.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,m.appendChild(l),m}function U(m){var w,f;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let b=document.createElement("img");return b.className=r.smartPhotoImg,b.src=(w=m.src)!=null?w:"",b.alt=(f=m.alt)!=null?f:"",b.addEventListener("dragstart",I=>I.preventDefault(),{signal:o}),l.appendChild(b),{imgWrap:l,img:b}}function oe(m,l){var b;c.list.replaceChildren(),(b=c.navList)==null||b.replaceChildren(),c.slides=new Map,m.forEach(w=>{var W,j;let f=document.createElement("li");f.setAttribute("role","group"),f.setAttribute("aria-roledescription","slide"),f.setAttribute("aria-label",`${w.index+1} of ${m.length}`);let I={li:f,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(w.processed){let{imgWrap:B,img:G}=U(w);f.appendChild(B),I.imgWrap=B,I.img=G}else{let B=$();f.appendChild(B),I.loaderWrap=B}if(c.list.appendChild(f),c.slides.set(w,I),c.navList){let B=document.createElement("li"),G=Ee();G.style.backgroundImage=`url("${Qe((W=w.thumb)!=null?W:"")}")`;let a=w.index;G.addEventListener("click",()=>i.onNavigate(a),{signal:o}),G.appendChild(ie(`go to ${(j=w.caption)!=null?j:""}`)),B.appendChild(G),c.navList.appendChild(B),I.navLink=G}}),J(l)}function re(m,l){var f;if(l.imgWrap||!m.processed)return l;let{imgWrap:b,img:w}=U(m);return(f=l.loaderWrap)==null||f.replaceWith(b),l.loaderWrap=null,l.imgWrap=b,l.img=w,l}function V(m){m&&document.activeElement&&m.contains(document.activeElement)&&c.caption.focus()}function J(m){let{viewer:l}=m;c.count.textContent=`${l.currentIndex+1}/${l.total}`,c.slides.forEach((b,w)=>{var W;let f=re(w,b),I=w.index===l.currentIndex;f.li.style.transform=`translate(${w.translateX}px,${w.translateY}px)`,f.li.classList.toggle("current",I),I?f.li.removeAttribute("aria-hidden"):f.li.setAttribute("aria-hidden","true"),I&&(c.caption.textContent=(W=w.caption)!=null?W:""),f.imgWrap&&f.img&&(f.imgWrap.style.transform=`translate(${w.x}px,${w.y}px) scale(${w.scale})`,f.img.style.width=`${w.width}px`,f.img.classList.toggle("active",l.appear),f.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),f.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),f.navLink&&(f.navLink.classList.toggle("current",I),I?f.navLink.setAttribute("aria-current","true"):f.navLink.removeAttribute("aria-current"))}),c.arrowLeft&&(l.showPrevArrow?c.arrowLeft.removeAttribute("aria-hidden"):(V(c.arrowLeft),c.arrowLeft.setAttribute("aria-hidden","true"))),c.arrowRight&&(l.showNextArrow?c.arrowRight.removeAttribute("aria-hidden"):(V(c.arrowRight),c.arrowRight.setAttribute("aria-hidden","true"))),c.arrows&&(l.hideUi&&V(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.nav&&(l.hideUi&&V(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ne(m){for(let[l,b]of c.slides)if(l.index===m.viewer.currentIndex)return b;return null}function se(m){let{viewer:l}=m,b=ne(m),w=b==null?void 0:b.img;w&&(w.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,w.classList.toggle(r.smartPhotoImgOnMove,l.scale),w.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),c.nav&&(l.hideUi&&V(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.arrows&&(l.hideUi&&V(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ae(m){let{viewer:l}=m;c.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,c.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function le(m){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=m.img,l.style.width=`${m.width}px`,l.style.height=`${m.height}px`,l.style.transform=`translate(${m.left}px,${m.top}px) scale(1)`,p.appendChild(l),c.imgClone=l}function he(){var m;(m=c.imgClone)==null||m.remove(),c.imgClone=null}function ue(){n.remove()}return{root:n,refs:c,render:J,syncSlides:oe,updatePhotoTransform:se,updateListTransform:ae,showAppearEffect:le,removeAppearEffect:he,destroy:ue}}var M=Z,k=ee;function _e(t){return t.length>0&&t[0]instanceof Element}function Je(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function ke(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var _=class{constructor(e,i){this.id=Je();this.abortController=new AbortController;this.isSmartPhoneFlag=K();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;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=q(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let r=this.itemsByElement.get(o);r&&this.openPhoto(r,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${k()}px`)};this.handleVisualViewportResize=()=>{this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!A(this.state))&&(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit())};this.handleResize=()=>{A(this.state)&&(this.updateViewportHeight(),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(!A(this.state))return;this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=M(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==M()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25)},25)};o(0)};this.rootSelector=typeof e=="string"?e:null,this.state=He(i!=null?i:{}),this.view=Ge({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Ye({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,r=s=>i.call(o,s);o.addEventListener(e,r,{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){this.state.viewer.currentIndex=Number.parseInt(String(e),10),this.state.viewer.currentIndex||(this.state.viewer.currentIndex=0),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=ke();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=z(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=Q(e,M(),k(),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.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin")},300)))}zoomOutPhoto(){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.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var p,d,v;let o=(p=i.group)!=null?p:this.state.viewer.currentGroup;if(o===null)return;let r=this.state.groups.get(o);if(!(r!=null&&r.length))return;let s=typeof e=="number"?r[e]:r.find(y=>y.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,u=(v=(d=i.trigger)!=null?d:s.element)!=null?v:n;this.openPhoto(s,u)}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)&&!_e(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,n;let i=q(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=pe(e,this.state.options,o,M());return fe(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=me(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=ze(e,o,M());return fe(this.state,r),this.loadAllFired.delete(i),r}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(d=>q(d)===e),o=new Set(i),r=(p=this.state.groups.get(e))!=null?p:[],s=new Map;r.forEach(d=>{d.element&&s.set(d.element,d)});let n=i.length!==r.length,u=i.map((d,v)=>{let y=s.get(d);if(y)return y.index!==v&&(n=!0,y.index=v),y;n=!0;let P=pe(d,this.state.options,v,M());return this.itemsByElement.set(d,P),P});return r.forEach(d=>{d.element&&!o.has(d.element)&&this.itemsByElement.delete(d.element)}),we(u,M()),this.state.groups.set(e,u),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=A(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=ke();this.setHash(Ne(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?Ve(this.state,Ce(e)):null}setPosByCurrentIndex(){let e=z(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=A(this.state);e&&De(e,M(),k(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){we(A(this.state),M())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;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.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=A(this.state);if(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(),ve(this.state),this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag){let o=z(this.state);this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=Q(o,M(),k(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}openPhotoWithViewTransition(e){var n,u;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(n=e==null?void 0:e.querySelector("img"))!=null?n:null;o&&(o.style.viewTransitionName=i);let r=()=>{o&&(o.style.viewTransitionName="");let p=this.currentImgElement();p&&(p.style.viewTransitionName="")},s=(u=document.startViewTransition)==null?void 0:u.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i});s==null||s.ready.catch(()=>{r()}),s==null||s.finished.then(r,r)}addAppearEffect(e,i){var O;let o=(O=e==null?void 0:e.querySelector("img"))!=null?O:null;if(!o){this.state.viewer.appear=!0;return}let r=Te(o),s=o.offsetWidth,n=o.offsetHeight,u=M(),p=k(),d=p-this.state.options.headerHeight-this.state.options.footerHeight,v=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?v=p/n:v=u/s:(s>=n?i.height<d?v=i.width/s:v=d/n:i.height<d?v=i.height/n:v=d/n,s*v>u&&(v=u/s));let y=(v-1)/2*s+(u-s*v)/2,P=(v-1)/2*n+(p-n*v)/2,S=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:S||i.src||"",afterX:y,afterY:P,scale:v}}runAppearEffect(e){this.view.showAppearEffect(e);let i=this.view.refs.imgClone;return new Promise(o=>{let r=()=>{i.removeEventListener("transitionend",r,!0),o()};i.addEventListener("transitionend",r,!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=M(),i=k();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(M()===e&&k()===i||(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.view.render(this.state)))})}openPhoto(e,i){let o=this.rootSelector?this.resyncGroupFromDom(e.groupId):!1;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=>{let o=this.view.refs.dialog,r=this.currentImgElement(),s=k(),n=e==="top"?`translateY(-${s}px)`:`translateY(${s}px)`,u=()=>{this.finishHideEffect===u&&(this.finishHideEffect=null,o.removeEventListener("transitionend",u,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=u,r&&(r.style.transform=n),o.addEventListener("transitionend",u,!0),this.scheduleTimeout(u,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;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=(r=e.src)!=null?r:""})}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=A(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).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=z(this.state);this.state.viewer.onMove=!1,ve(this.state),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(r=>r!==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",Ae(o))}fireEvent(e){Le(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:()=>this.zoomPhoto(),onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},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 We=_;var ye=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new We(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],ye);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&ye(e)}var ht=ye;})();
package/js/smartphoto.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * SmartPhoto v2.1.9
2
+ * SmartPhoto v2.1.11
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
@@ -79,6 +79,16 @@ var SmartPhoto = (() => {
79
79
  }
80
80
  return data;
81
81
  };
82
+ var getWindowWidth = () => {
83
+ return document.documentElement.clientWidth;
84
+ };
85
+ var getWindowHeight = () => {
86
+ const visualViewport = window.visualViewport;
87
+ if (visualViewport) {
88
+ return visualViewport.height * visualViewport.scale;
89
+ }
90
+ return document.documentElement.clientHeight;
91
+ };
82
92
  var getViewPos = (element) => {
83
93
  return {
84
94
  left: element.getBoundingClientRect().left,
@@ -436,8 +446,8 @@ var SmartPhoto = (() => {
436
446
  }
437
447
  function windowSize() {
438
448
  return {
439
- width: document.documentElement.clientWidth,
440
- height: document.documentElement.clientHeight
449
+ width: getWindowWidth(),
450
+ height: getWindowHeight()
441
451
  };
442
452
  }
443
453
  function createGestures({ state, callbacks }, { signal }) {
@@ -1164,16 +1174,8 @@ var SmartPhoto = (() => {
1164
1174
  }
1165
1175
 
1166
1176
  // src/core/index.ts
1167
- function getWindowWidth() {
1168
- return document.documentElement.clientWidth;
1169
- }
1170
- function getWindowHeight() {
1171
- const visualViewport = window.visualViewport;
1172
- if (visualViewport) {
1173
- return visualViewport.height * visualViewport.scale;
1174
- }
1175
- return document.documentElement.clientHeight;
1176
- }
1177
+ var getWindowWidth2 = getWindowWidth;
1178
+ var getWindowHeight2 = getWindowHeight;
1177
1179
  function isElementArray(source) {
1178
1180
  return source.length > 0 && source[0] instanceof Element;
1179
1181
  }
@@ -1244,7 +1246,7 @@ var SmartPhoto = (() => {
1244
1246
  this.updateViewportHeight = () => {
1245
1247
  this.view.refs.dialog.style.setProperty(
1246
1248
  "--smartphoto-vh",
1247
- `${getWindowHeight()}px`
1249
+ `${getWindowHeight2()}px`
1248
1250
  );
1249
1251
  };
1250
1252
  // iOS Safari 等ではアドレスバーの表示/非表示に伴う visualViewport の変化が
@@ -1296,11 +1298,11 @@ var SmartPhoto = (() => {
1296
1298
  this.setHashByCurrentIndex();
1297
1299
  this.setSizeByScreen();
1298
1300
  this.commit();
1299
- const prevWidth = getWindowWidth();
1301
+ const prevWidth = getWindowWidth2();
1300
1302
  const timeout = 500;
1301
1303
  const poll = (time) => {
1302
1304
  this.scheduleTimeout(() => {
1303
- if (prevWidth !== getWindowWidth()) {
1305
+ if (prevWidth !== getWindowWidth2()) {
1304
1306
  this.updateViewportHeight();
1305
1307
  this.resetTranslateCurrent();
1306
1308
  this.setPosByCurrentIndex();
@@ -1441,8 +1443,8 @@ var SmartPhoto = (() => {
1441
1443
  this.state.viewer.hideUi = true;
1442
1444
  this.state.viewer.scaleSize = scaleBorder(
1443
1445
  item,
1444
- getWindowWidth(),
1445
- getWindowHeight(),
1446
+ getWindowWidth2(),
1447
+ getWindowHeight2(),
1446
1448
  this.isSmartPhoneFlag
1447
1449
  );
1448
1450
  if (this.state.viewer.scaleSize <= 1) {
@@ -1532,7 +1534,7 @@ var SmartPhoto = (() => {
1532
1534
  element,
1533
1535
  this.state.options,
1534
1536
  index,
1535
- getWindowWidth()
1537
+ getWindowWidth2()
1536
1538
  );
1537
1539
  addItemToGroup(this.state, item);
1538
1540
  this.loadAllFired.delete(groupId);
@@ -1543,7 +1545,7 @@ var SmartPhoto = (() => {
1543
1545
  var _a, _b;
1544
1546
  const groupId = groupIdFromSlide(slide);
1545
1547
  const index = (_b = (_a = this.state.groups.get(groupId)) == null ? void 0 : _a.length) != null ? _b : 0;
1546
- const item = itemFromSlide(slide, index, getWindowWidth());
1548
+ const item = itemFromSlide(slide, index, getWindowWidth2());
1547
1549
  addItemToGroup(this.state, item);
1548
1550
  this.loadAllFired.delete(groupId);
1549
1551
  return item;
@@ -1599,7 +1601,7 @@ var SmartPhoto = (() => {
1599
1601
  el,
1600
1602
  this.state.options,
1601
1603
  index,
1602
- getWindowWidth()
1604
+ getWindowWidth2()
1603
1605
  );
1604
1606
  this.itemsByElement.set(el, item);
1605
1607
  return item;
@@ -1609,7 +1611,7 @@ var SmartPhoto = (() => {
1609
1611
  this.itemsByElement.delete(it.element);
1610
1612
  }
1611
1613
  });
1612
- resetTranslate(rebuilt, getWindowWidth());
1614
+ resetTranslate(rebuilt, getWindowWidth2());
1613
1615
  this.state.groups.set(groupId, rebuilt);
1614
1616
  if (changed) {
1615
1617
  this.loadAllFired.delete(groupId);
@@ -1661,15 +1663,15 @@ var SmartPhoto = (() => {
1661
1663
  }
1662
1664
  sizeItems(
1663
1665
  items,
1664
- getWindowWidth(),
1665
- getWindowHeight(),
1666
+ getWindowWidth2(),
1667
+ getWindowHeight2(),
1666
1668
  this.state.options.headerHeight,
1667
1669
  this.state.options.footerHeight
1668
1670
  );
1669
1671
  }
1670
1672
  // resize/orientationchange ハンドラは呼び出し前に currentItems の存在を確認済み
1671
1673
  resetTranslateCurrent() {
1672
- resetTranslate(currentItems(this.state), getWindowWidth());
1674
+ resetTranslate(currentItems(this.state), getWindowWidth2());
1673
1675
  }
1674
1676
  currentImgElement() {
1675
1677
  for (const [item, slideRefs] of this.view.refs.slides) {
@@ -1717,8 +1719,8 @@ var SmartPhoto = (() => {
1717
1719
  this.state.viewer.hideUi = true;
1718
1720
  this.state.viewer.scaleSize = scaleBorder(
1719
1721
  item,
1720
- getWindowWidth(),
1721
- getWindowHeight(),
1722
+ getWindowWidth2(),
1723
+ getWindowHeight2(),
1722
1724
  this.isSmartPhoneFlag
1723
1725
  );
1724
1726
  }
@@ -1771,8 +1773,8 @@ var SmartPhoto = (() => {
1771
1773
  const pos = getViewPos(img);
1772
1774
  const width = img.offsetWidth;
1773
1775
  const height = img.offsetHeight;
1774
- const toX = getWindowWidth();
1775
- const toY = getWindowHeight();
1776
+ const toX = getWindowWidth2();
1777
+ const toY = getWindowHeight2();
1776
1778
  const screenY = toY - this.state.options.headerHeight - this.state.options.footerHeight;
1777
1779
  let scale = 1;
1778
1780
  if (this.state.options.resizeStyle === "fill" && this.isSmartPhoneFlag) {
@@ -1859,13 +1861,13 @@ var SmartPhoto = (() => {
1859
1861
  // dialog が開いてスクロールバーが消えた後の幅とズレる。次の描画フレームで
1860
1862
  // 開いた後の正しいサイズを使って再計算し、必要なら再描画する
1861
1863
  resyncSizeAfterOpen() {
1862
- const winWidthBefore = getWindowWidth();
1863
- const winHeightBefore = getWindowHeight();
1864
+ const winWidthBefore = getWindowWidth2();
1865
+ const winHeightBefore = getWindowHeight2();
1864
1866
  requestAnimationFrame(() => {
1865
1867
  if (!this.state.viewer.isOpen) {
1866
1868
  return;
1867
1869
  }
1868
- if (getWindowWidth() === winWidthBefore && getWindowHeight() === winHeightBefore) {
1870
+ if (getWindowWidth2() === winWidthBefore && getWindowHeight2() === winHeightBefore) {
1869
1871
  return;
1870
1872
  }
1871
1873
  this.resetTranslateCurrent();
@@ -1895,7 +1897,7 @@ var SmartPhoto = (() => {
1895
1897
  return new Promise((resolve) => {
1896
1898
  const dialog = this.view.refs.dialog;
1897
1899
  const img = this.currentImgElement();
1898
- const height = getWindowHeight();
1900
+ const height = getWindowHeight2();
1899
1901
  const applied = dir === "top" ? `translateY(-${height}px)` : `translateY(${height}px)`;
1900
1902
  const finish = () => {
1901
1903
  if (this.finishHideEffect !== finish) {
@@ -1958,6 +1960,9 @@ var SmartPhoto = (() => {
1958
1960
  }
1959
1961
  if (promises.length) {
1960
1962
  Promise.all(promises).then(() => {
1963
+ if (!this.state.viewer.isOpen) {
1964
+ return;
1965
+ }
1961
1966
  this.initPhoto();
1962
1967
  this.commit();
1963
1968
  });
@@ -1987,6 +1992,9 @@ var SmartPhoto = (() => {
1987
1992
  this.loadNeighborItems();
1988
1993
  if (item && !item.loaded) {
1989
1994
  this.loadItem(item).then(() => {
1995
+ if (!this.state.viewer.isOpen) {
1996
+ return;
1997
+ }
1990
1998
  this.initPhoto();
1991
1999
  this.commit();
1992
2000
  });
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * SmartPhoto v2.1.9
2
+ * SmartPhoto v2.1.11
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
6
- "use strict";var SmartPhoto=(()=>{var ue=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var ke=Object.prototype.hasOwnProperty;var $e=(t,e)=>{for(var i in e)ue(t,i,{get:e[i],enumerable:!0})},We=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Re(e))!ke.call(t,r)&&r!==i&&ue(t,r,{get:()=>e[r],enumerable:!(o=Fe(e,r))||o.enumerable});return t};var Ue=t=>We(ue({},"__esModule",{value:!0}),t);var it={};$e(it,{default:()=>tt});var J=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};function ye(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let r=e[o];if(r){for(let s in r)if(Object.hasOwn(r,s)){let n=r[s];n&&typeof n=="object"?t[s]=ye((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var Se=ye,Ie=(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)},xe=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),r=o[0],s=o.length>1?o.slice(1).join("="):r;e[r]=decodeURIComponent(s)}return e},Le=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var Pe=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},_e=.179,qe=([t,e,i])=>{let[o,r,s]=[t,e,i].map(n=>{let u=n/255;return u<=.03928?u/12.92:((u+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*s},Ce=t=>{let e=t.trim(),i=Pe(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=Pe(getComputedStyle(o).color),document.body.removeChild(o)}return i&&qe(i)>_e?"#000":"#fff"};var je={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,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:450};function Te(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Te(i)}),Object.freeze(t)}function Ae(t){return{options:Te(Se({},je,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 q(t){return t.getAttribute("data-group")||"nogroup"}function de(t){return t.group||"nogroup"}function me(t,e,i,o){let r=q(t),s=t.getAttribute("href"),n=t.querySelector("img"),u=s;n&&(n.getAttribute(e.lazyAttribute)?u=n.getAttribute(e.lazyAttribute):n.currentSrc?u=n.currentSrc:u=n.src);let p="";n!=null&&n.getAttribute("alt")?p=n.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:u,caption:t.getAttribute("data-caption"),alt:p,groupId:r,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 Me(t,e,i){var c,v,b,y,S;let o=de(t),r=t.src,s=(c=t.thumb)!=null?c:r,n=(v=t.caption)!=null?v:null,u=(y=(b=t.alt)!=null?b:n)!=null?y:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:u,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:(S=t.id)!=null?S:e,loaded:p,processed:!1,element:null}}function pe(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 A(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function z(t){var i;let e=A(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function fe(t){let e=A(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,r=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),r!==-1&&(t.viewer.prev=r,t.viewer.showPrevArrow=!0)}function ve(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function Z(t,e){let i=10**e;return Math.round(t*i)/i}function j(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function He(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,u,p,c;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(c=(o-s)/2,u=-1*c):(c=(s-o)/2,u=-1*c),{minX:Z(n,6)*e.scaleSize,minY:Z(u,6)*e.scaleSize,maxX:Z(p,6)*e.scaleSize,maxY:Z(c,6)*e.scaleSize}}function ze(t,e,i,o,r){let s=i-(o+r);t.forEach(n=>{n.loaded&&(n.processed=!0,n.scale=s/n.height,n.height<s&&(n.scale=1),n.x=(n.scale-1)/2*n.width+(e-n.width*n.scale)/2,n.y=(n.scale-1)/2*n.height+(i-n.height*n.scale)/2,n.width*n.scale>e&&(n.scale=e/n.width,n.x=(n.scale-1)/2*n.width))})}function Oe(t){let e=z(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function De(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(r=>{e.group===r.groupId&&e.photo===r.id&&(i=r)})}),i}function we(t,e){let i=10**e;return Math.round(t*i)/i}function $(t){return{x:t.pageX,y:t.pageY}}function Ne(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var Ke=10;function Qe(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ve(){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}function Be({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,u=null,p=null,c=null,v=0,b=!1,y=null,S=null,O=0,D=0,H=!1,Y=0,I=null,C=0,N=0;function d(){return J()}function W(a){let{width:h,height:E}=Ve();return He(a,t.viewer,h,E)}function U(a){let{width:h,height:E}=Ve();return j(a,h,E,d())}function te(a,h){let E=z(t),g=W(E);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 ie=setInterval(()=>{if(H||s||b||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=C,t.viewer.photoPosY+=N;let a=z(t);if(!a)return;let h=W(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,C*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,C*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,N*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,N*=-.2);let E=Qe(C,N),g=E.force-t.options.registance;Math.abs(g)<.5||(C=Math.cos(E.theta)*g,N=Math.sin(E.theta)*g,e.onPhotoDragMove())},t.options.forceInterval);function V(a,h){(a>5||a<-5)&&(C+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(N+=h*.05)}function Q(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||H||s||b||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?V(a.gamma,a.beta):h===90?V(a.beta,a.gamma):h===-90?V(-a.beta,-a.gamma):h===180&&V(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",Q,{signal:i});function oe(){H=!0,s=!1,b=!1;let a=Array.from(o.values());Y=Ne(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function re(a){let h=$(a);s=!0,n=!0,u=h,p=h,v=Date.now()}function ne(a){b=!0;let h=$(a);S=h,y=h}function se(a){var h,E;try{(E=(h=a.currentTarget).setPointerCapture)==null||E.call(h,a.pointerId)}catch(g){}if(o.set(a.pointerId,$(a)),o.size>1){oe();return}if(t.viewer.scale){ne(a);return}re(a)}function ae(){I===null&&(I=requestAnimationFrame(()=>{I=null,e.onGestureMove()}))}function le(){I!==null&&(cancelAnimationFrame(I),I=null,e.onGestureMove())}function m(){let a=Array.from(o.values()),h=Ne(a[0],a[1]),E=(h-Y)/100,g=t.viewer.scaleSize,L=t.viewer.photoPosX,T=t.viewer.photoPosY;t.viewer.scaleSize+=we(E,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<g&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-g)*L,t.viewer.photoPosY=(1+t.viewer.scaleSize-g)*T);let X=z(t);if(X){let he=U(X);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>he}Y=h,ae()}function l(a){let h=$(a),E=h.x-p.x,g=h.y-u.y;n&&(e.onSwipeStart(),n=!1,c=Math.abs(E)>Math.abs(g)?"horizontal":"vertical"),c==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=g,p=h,e.onSwipeMove()}function P(a){let h=$(a),E=h.x-S.x,g=h.y-S.y,L=we(t.viewer.scaleSize*E,6),T=we(t.viewer.scaleSize*g,6);t.viewer.photoPosX+=L,O=L,t.viewer.photoPosY+=T,D=T,S=h,e.onPhotoDragMove()}function w(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,$(a)),H){m();return}if(b){P(a);return}l(a)}}function f(){H=!1,le();let a=z(t);if(!a)return;let h=U(a);t.viewer.scaleSize>h||(t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scale=!1,t.viewer.scaleSize=1,t.viewer.hideUi=!1,e.onGestureEnd())}function x(){var Ee;s=!1;let a=u,h=p,E=Date.now(),g=r-E,L=h.x-a.x,T=h.y-a.y,X=L===0&&T===0;if(!d()&&X){e.onTap();return}if(Math.abs(g)<=500&&X){e.onTap();return}r=E;let he=(Ee=A(t))!=null?Ee:[];if(c==="horizontal"){let k="stay",Ge=Math.max(E-v,1),be=Math.abs(L)>=Ke&&Math.abs(L)/Ge>=t.options.swipeVelocity;(L>=t.options.swipeOffset||be&&L>0)&&t.viewer.currentIndex!==0?k="prev":(L<=-t.options.swipeOffset||be&&L<0)&&t.viewer.currentIndex!==he.length-1&&(k="next"),e.onSwipeEnd(k)}else{let k="stay";t.options.swipeBottomToClose&&T>=t.options.swipeOffset?k="close-bottom":t.options.swipeTopToClose&&T<=-t.options.swipeOffset&&(k="close-top"),e.onSwipeEnd(k)}}function R(){b=!1;let a=S,h=y;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let E=z(t);if(!E){e.onPhotoDragEnd(null);return}let g=W(E),L=t.options.swipeOffset*t.viewer.scaleSize,T=0,X=0;if(t.viewer.photoPosX>g.maxX?T=-1:t.viewer.photoPosX<g.minX&&(T=1),t.viewer.photoPosY>g.maxY?X=-1:t.viewer.photoPosY<g.minY&&(X=1),t.viewer.photoPosX-g.maxX>L&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(g.minX-t.viewer.photoPosX>L&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}T===0&&X===0?(C=O/5,N=D/5):te(T,X),e.onPhotoDragEnd(null)}function _(a){if(o.delete(a.pointerId),H){o.size<2&&f();return}if(b){R();return}s&&x()}function B(...a){for(let h of a)h.addEventListener("pointerdown",se,{signal:i}),h.addEventListener("pointermove",w,{signal:i}),h.addEventListener("pointerup",_,{signal:i}),h.addEventListener("pointercancel",_,{signal:i})}function G(){clearInterval(ie),I!==null&&(cancelAnimationFrame(I),I=null)}return{attach:B,detach:G}}function ee(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function ge(){let t=document.createElement("button");return t.type="button",t}function Je(t){return t.replace(/"/g,'\\"')}function Xe({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let u=document.createElement("dialog");u.className=r.smartPhoto,u.setAttribute("aria-labelledby",`smartphoto-${t}-title`),u.style.display="none",u.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let c=document.createElement("div");c.className=r.smartPhotoInner;let v=document.createElement("div");v.className=r.smartPhotoHeader;let b=document.createElement("span");b.className=r.smartPhotoCount;let y=document.createElement("h1");y.id=`smartphoto-${t}-title`,y.className=r.smartPhotoCaption,y.setAttribute("tabindex","-1");let S=document.createElement("button");S.className=r.smartPhotoDismiss,S.appendChild(ee(s.closeDialog)),S.addEventListener("click",()=>i.onDismiss(),{signal:o}),v.append(b,y,S);let O=document.createElement("div");O.className=r.smartPhotoContent,O.addEventListener("click",m=>{m.target===O&&i.onBackdropClick()},{signal:o});let D=document.createElement("ul");D.className=r.smartPhotoList,D.setAttribute("role","region"),D.setAttribute("aria-roledescription","carousel"),D.setAttribute("aria-label",s.carouselLabel),D.setAttribute("aria-live","polite"),D.setAttribute("aria-atomic","false"),c.append(v,O,D);let H=null,Y=null,I=null;if(e.arrows){H=document.createElement("ul"),H.className=r.smartPhotoArrows,Y=document.createElement("li"),Y.className=r.smartPhotoArrowLeft;let m=ge();m.appendChild(ee(s.gotoPrevImage)),m.addEventListener("click",()=>i.onPrev(),{signal:o}),Y.appendChild(m),I=document.createElement("li"),I.className=r.smartPhotoArrowRight;let l=ge();l.appendChild(ee(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),I.appendChild(l),H.append(Y,I),c.appendChild(H)}let C=null,N=null;e.nav&&(C=document.createElement("nav"),C.className=r.smartPhotoNav,C.setAttribute("aria-label","Choose slide to display"),N=document.createElement("ul"),C.appendChild(N),c.appendChild(C)),p.appendChild(c),u.appendChild(p),n.appendChild(u);let d={dialog:u,count:b,caption:y,dismiss:S,content:O,list:D,arrows:H,arrowLeft:Y,arrowRight:I,nav:C,navList:N,slides:new Map,imgClone:null};function W(){let m=document.createElement("div");m.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,m.appendChild(l),m}function U(m){var w,f;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let P=document.createElement("img");return P.className=r.smartPhotoImg,P.src=(w=m.src)!=null?w:"",P.alt=(f=m.alt)!=null?f:"",P.addEventListener("dragstart",x=>x.preventDefault(),{signal:o}),l.appendChild(P),{imgWrap:l,img:P}}function te(m,l){var P;d.list.replaceChildren(),(P=d.navList)==null||P.replaceChildren(),d.slides=new Map,m.forEach(w=>{var R,_;let f=document.createElement("li");f.setAttribute("role","group"),f.setAttribute("aria-roledescription","slide"),f.setAttribute("aria-label",`${w.index+1} of ${m.length}`);let x={li:f,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(w.processed){let{imgWrap:B,img:G}=U(w);f.appendChild(B),x.imgWrap=B,x.img=G}else{let B=W();f.appendChild(B),x.loaderWrap=B}if(d.list.appendChild(f),d.slides.set(w,x),d.navList){let B=document.createElement("li"),G=ge();G.style.backgroundImage=`url("${Je((R=w.thumb)!=null?R:"")}")`;let a=w.index;G.addEventListener("click",()=>i.onNavigate(a),{signal:o}),G.appendChild(ee(`go to ${(_=w.caption)!=null?_:""}`)),B.appendChild(G),d.navList.appendChild(B),x.navLink=G}}),Q(l)}function ie(m,l){var f;if(l.imgWrap||!m.processed)return l;let{imgWrap:P,img:w}=U(m);return(f=l.loaderWrap)==null||f.replaceWith(P),l.loaderWrap=null,l.imgWrap=P,l.img=w,l}function V(m){m&&document.activeElement&&m.contains(document.activeElement)&&d.caption.focus()}function Q(m){let{viewer:l}=m;d.count.textContent=`${l.currentIndex+1}/${l.total}`,d.slides.forEach((P,w)=>{var R;let f=ie(w,P),x=w.index===l.currentIndex;f.li.style.transform=`translate(${w.translateX}px,${w.translateY}px)`,f.li.classList.toggle("current",x),x?f.li.removeAttribute("aria-hidden"):f.li.setAttribute("aria-hidden","true"),x&&(d.caption.textContent=(R=w.caption)!=null?R:""),f.imgWrap&&f.img&&(f.imgWrap.style.transform=`translate(${w.x}px,${w.y}px) scale(${w.scale})`,f.img.style.width=`${w.width}px`,f.img.classList.toggle("active",l.appear),f.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),f.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),f.navLink&&(f.navLink.classList.toggle("current",x),x?f.navLink.setAttribute("aria-current","true"):f.navLink.removeAttribute("aria-current"))}),d.arrowLeft&&(l.showPrevArrow?d.arrowLeft.removeAttribute("aria-hidden"):(V(d.arrowLeft),d.arrowLeft.setAttribute("aria-hidden","true"))),d.arrowRight&&(l.showNextArrow?d.arrowRight.removeAttribute("aria-hidden"):(V(d.arrowRight),d.arrowRight.setAttribute("aria-hidden","true"))),d.arrows&&(l.hideUi&&V(d.arrows),d.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),d.nav&&(l.hideUi&&V(d.nav),d.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function oe(m){for(let[l,P]of d.slides)if(l.index===m.viewer.currentIndex)return P;return null}function re(m){let{viewer:l}=m,P=oe(m),w=P==null?void 0:P.img;w&&(w.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,w.classList.toggle(r.smartPhotoImgOnMove,l.scale),w.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),d.nav&&(l.hideUi&&V(d.nav),d.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),d.arrows&&(l.hideUi&&V(d.arrows),d.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ne(m){let{viewer:l}=m;d.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,d.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function se(m){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=m.img,l.style.width=`${m.width}px`,l.style.height=`${m.height}px`,l.style.transform=`translate(${m.left}px,${m.top}px) scale(1)`,p.appendChild(l),d.imgClone=l}function ae(){var m;(m=d.imgClone)==null||m.remove(),d.imgClone=null}function le(){n.remove()}return{root:n,refs:d,render:Q,syncSlides:te,updatePhotoTransform:re,updateListTransform:ne,showAppearEffect:se,removeAppearEffect:ae,destroy:le}}function M(){return document.documentElement.clientWidth}function F(){let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight}function Ze(t){return t.length>0&&t[0]instanceof Element}function et(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function Ye(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var K=class{constructor(e,i){this.id=et();this.abortController=new AbortController;this.isSmartPhoneFlag=J();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;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=q(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let r=this.itemsByElement.get(o);r&&this.openPhoto(r,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${F()}px`)};this.handleVisualViewportResize=()=>{this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!A(this.state))&&(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit())};this.handleResize=()=>{A(this.state)&&(this.updateViewportHeight(),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(!A(this.state))return;this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=M(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==M()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25)},25)};o(0)};this.rootSelector=typeof e=="string"?e:null,this.state=Ae(i!=null?i:{}),this.view=Xe({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Be({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,r=s=>i.call(o,s);o.addEventListener(e,r,{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){this.state.viewer.currentIndex=Number.parseInt(String(e),10),this.state.viewer.currentIndex||(this.state.viewer.currentIndex=0),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=Ye();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=z(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=j(e,M(),F(),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.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin")},300)))}zoomOutPhoto(){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.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var p,c,v;let o=(p=i.group)!=null?p:this.state.viewer.currentGroup;if(o===null)return;let r=this.state.groups.get(o);if(!(r!=null&&r.length))return;let s=typeof e=="number"?r[e]:r.find(b=>b.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,u=(v=(c=i.trigger)!=null?c:s.element)!=null?v:n;this.openPhoto(s,u)}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)&&!Ze(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,n;let i=q(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=me(e,this.state.options,o,M());return pe(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=de(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Me(e,o,M());return pe(this.state,r),this.loadAllFired.delete(i),r}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=>q(c)===e),o=new Set(i),r=(p=this.state.groups.get(e))!=null?p:[],s=new Map;r.forEach(c=>{c.element&&s.set(c.element,c)});let n=i.length!==r.length,u=i.map((c,v)=>{let b=s.get(c);if(b)return b.index!==v&&(n=!0,b.index=v),b;n=!0;let y=me(c,this.state.options,v,M());return this.itemsByElement.set(c,y),y});return r.forEach(c=>{c.element&&!o.has(c.element)&&this.itemsByElement.delete(c.element)}),ve(u,M()),this.state.groups.set(e,u),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=A(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=Ye();this.setHash(Oe(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?De(this.state,xe(e)):null}setPosByCurrentIndex(){let e=z(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=A(this.state);e&&ze(e,M(),F(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){ve(A(this.state),M())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;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.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=A(this.state);if(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(),fe(this.state),this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag){let o=z(this.state);this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=j(o,M(),F(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}openPhotoWithViewTransition(e){var n,u;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(n=e==null?void 0:e.querySelector("img"))!=null?n:null;o&&(o.style.viewTransitionName=i);let r=()=>{o&&(o.style.viewTransitionName="");let p=this.currentImgElement();p&&(p.style.viewTransitionName="")},s=(u=document.startViewTransition)==null?void 0:u.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i});s==null||s.ready.catch(()=>{r()}),s==null||s.finished.then(r,r)}addAppearEffect(e,i){var O;let o=(O=e==null?void 0:e.querySelector("img"))!=null?O:null;if(!o){this.state.viewer.appear=!0;return}let r=Le(o),s=o.offsetWidth,n=o.offsetHeight,u=M(),p=F(),c=p-this.state.options.headerHeight-this.state.options.footerHeight,v=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?v=p/n:v=u/s:(s>=n?i.height<c?v=i.width/s:v=c/n:i.height<c?v=i.height/n:v=c/n,s*v>u&&(v=u/s));let b=(v-1)/2*s+(u-s*v)/2,y=(v-1)/2*n+(p-n*v)/2,S=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:S||i.src||"",afterX:b,afterY:y,scale:v}}runAppearEffect(e){this.view.showAppearEffect(e);let i=this.view.refs.imgClone;return new Promise(o=>{let r=()=>{i.removeEventListener("transitionend",r,!0),o()};i.addEventListener("transitionend",r,!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=M(),i=F();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(M()===e&&F()===i||(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.view.render(this.state)))})}openPhoto(e,i){let o=this.rootSelector?this.resyncGroupFromDom(e.groupId):!1;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=>{let o=this.view.refs.dialog,r=this.currentImgElement(),s=F(),n=e==="top"?`translateY(-${s}px)`:`translateY(${s}px)`,u=()=>{this.finishHideEffect===u&&(this.finishHideEffect=null,o.removeEventListener("transitionend",u,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=u,r&&(r.style.transform=n),o.addEventListener("transitionend",u,!0),this.scheduleTimeout(u,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;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=(r=e.src)!=null?r:""})}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=A(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).then(()=>{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=z(this.state);this.state.viewer.onMove=!1,fe(this.state),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.initPhoto(),this.commit()})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(r=>r!==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",Ce(o))}fireEvent(e){Ie(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:()=>this.zoomPhoto(),onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},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 tt=K;return Ue(it);})();
6
+ "use strict";var SmartPhoto=(()=>{var ce=Object.defineProperty;var Re=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var $e=Object.prototype.hasOwnProperty;var Ue=(t,e)=>{for(var i in e)ce(t,i,{get:e[i],enumerable:!0})},_e=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ke(e))!$e.call(t,r)&&r!==i&&ce(t,r,{get:()=>e[r],enumerable:!(o=Re(e,r))||o.enumerable});return t};var qe=t=>_e(ce({},"__esModule",{value:!0}),t);var rt={};Ue(rt,{default:()=>ot});var J=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};function xe(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let r=e[o];if(r){for(let s in r)if(Object.hasOwn(r,s)){let n=r[s];n&&typeof n=="object"?t[s]=xe((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var Ie=xe,Le=(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)},Ce=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),r=o[0],s=o.length>1?o.slice(1).join("="):r;e[r]=decodeURIComponent(s)}return e},Z=()=>document.documentElement.clientWidth,ee=()=>{let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight},Te=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var Se=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},je=.179,Ke=([t,e,i])=>{let[o,r,s]=[t,e,i].map(n=>{let u=n/255;return u<=.03928?u/12.92:((u+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*s},Ae=t=>{let e=t.trim(),i=Se(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=Se(getComputedStyle(o).color),document.body.removeChild(o)}return i&&Ke(i)>je?"#000":"#fff"};var Qe={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,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:450};function Me(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Me(i)}),Object.freeze(t)}function He(t){return{options:Me(Ie({},Qe,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 q(t){return t.getAttribute("data-group")||"nogroup"}function pe(t){return t.group||"nogroup"}function fe(t,e,i,o){let r=q(t),s=t.getAttribute("href"),n=t.querySelector("img"),u=s;n&&(n.getAttribute(e.lazyAttribute)?u=n.getAttribute(e.lazyAttribute):n.currentSrc?u=n.currentSrc:u=n.src);let p="";n!=null&&n.getAttribute("alt")?p=n.getAttribute("alt"):t.getAttribute("data-caption")?p=t.getAttribute("data-caption"):p=s!=null?s:"";let d=t.getAttribute("data-id");return{src:s,thumb:u,caption:t.getAttribute("data-caption"),alt:p,groupId:r,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:d||i,loaded:!1,processed:!1,element:t}}function ze(t,e,i){var d,v,b,y,S;let o=pe(t),r=t.src,s=(d=t.thumb)!=null?d:r,n=(v=t.caption)!=null?v:null,u=(y=(b=t.alt)!=null?b:n)!=null?y:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:u,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:(S=t.id)!=null?S:e,loaded:p,processed:!1,element:null}}function ve(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 A(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function z(t){var i;let e=A(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function we(t){let e=A(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,r=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),r!==-1&&(t.viewer.prev=r,t.viewer.showPrevArrow=!0)}function ge(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function te(t,e){let i=10**e;return Math.round(t*i)/i}function j(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Oe(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,u,p,d;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(d=(o-s)/2,u=-1*d):(d=(s-o)/2,u=-1*d),{minX:te(n,6)*e.scaleSize,minY:te(u,6)*e.scaleSize,maxX:te(p,6)*e.scaleSize,maxY:te(d,6)*e.scaleSize}}function De(t,e,i,o,r){let s=i-(o+r);t.forEach(n=>{n.loaded&&(n.processed=!0,n.scale=s/n.height,n.height<s&&(n.scale=1),n.x=(n.scale-1)/2*n.width+(e-n.width*n.scale)/2,n.y=(n.scale-1)/2*n.height+(i-n.height*n.scale)/2,n.width*n.scale>e&&(n.scale=e/n.width,n.x=(n.scale-1)/2*n.width))})}function Ne(t){let e=z(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function Ve(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(r=>{e.group===r.groupId&&e.photo===r.id&&(i=r)})}),i}function Ee(t,e){let i=10**e;return Math.round(t*i)/i}function k(t){return{x:t.pageX,y:t.pageY}}function Be(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var Je=10;function Ze(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Xe(){return{width:Z(),height:ee()}}function Ye({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,u=null,p=null,d=null,v=0,b=!1,y=null,S=null,O=0,D=0,H=!1,Y=0,x=null,C=0,N=0;function c(){return J()}function $(a){let{width:h,height:E}=Xe();return Oe(a,t.viewer,h,E)}function U(a){let{width:h,height:E}=Xe();return j(a,h,E,c())}function oe(a,h){let E=z(t),g=$(E);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 re=setInterval(()=>{if(H||s||b||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=C,t.viewer.photoPosY+=N;let a=z(t);if(!a)return;let h=$(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,C*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,C*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,N*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,N*=-.2);let E=Ze(C,N),g=E.force-t.options.registance;Math.abs(g)<.5||(C=Math.cos(E.theta)*g,N=Math.sin(E.theta)*g,e.onPhotoDragMove())},t.options.forceInterval);function V(a,h){(a>5||a<-5)&&(C+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(N+=h*.05)}function Q(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||H||s||b||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?V(a.gamma,a.beta):h===90?V(a.beta,a.gamma):h===-90?V(-a.beta,-a.gamma):h===180&&V(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",Q,{signal:i});function ne(){H=!0,s=!1,b=!1;let a=Array.from(o.values());Y=Be(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function se(a){let h=k(a);s=!0,n=!0,u=h,p=h,v=Date.now()}function ae(a){b=!0;let h=k(a);S=h,y=h}function le(a){var h,E;try{(E=(h=a.currentTarget).setPointerCapture)==null||E.call(h,a.pointerId)}catch(g){}if(o.set(a.pointerId,k(a)),o.size>1){ne();return}if(t.viewer.scale){ae(a);return}se(a)}function he(){x===null&&(x=requestAnimationFrame(()=>{x=null,e.onGestureMove()}))}function ue(){x!==null&&(cancelAnimationFrame(x),x=null,e.onGestureMove())}function m(){let a=Array.from(o.values()),h=Be(a[0],a[1]),E=(h-Y)/100,g=t.viewer.scaleSize,L=t.viewer.photoPosX,T=t.viewer.photoPosY;t.viewer.scaleSize+=Ee(E,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<g&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-g)*L,t.viewer.photoPosY=(1+t.viewer.scaleSize-g)*T);let X=z(t);if(X){let de=U(X);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>de}Y=h,he()}function l(a){let h=k(a),E=h.x-p.x,g=h.y-u.y;n&&(e.onSwipeStart(),n=!1,d=Math.abs(E)>Math.abs(g)?"horizontal":"vertical"),d==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=g,p=h,e.onSwipeMove()}function P(a){let h=k(a),E=h.x-S.x,g=h.y-S.y,L=Ee(t.viewer.scaleSize*E,6),T=Ee(t.viewer.scaleSize*g,6);t.viewer.photoPosX+=L,O=L,t.viewer.photoPosY+=T,D=T,S=h,e.onPhotoDragMove()}function w(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,k(a)),H){m();return}if(b){P(a);return}l(a)}}function f(){H=!1,ue();let a=z(t);if(!a)return;let h=U(a);t.viewer.scaleSize>h||(t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scale=!1,t.viewer.scaleSize=1,t.viewer.hideUi=!1,e.onGestureEnd())}function I(){var Pe;s=!1;let a=u,h=p,E=Date.now(),g=r-E,L=h.x-a.x,T=h.y-a.y,X=L===0&&T===0;if(!c()&&X){e.onTap();return}if(Math.abs(g)<=500&&X){e.onTap();return}r=E;let de=(Pe=A(t))!=null?Pe:[];if(d==="horizontal"){let R="stay",Fe=Math.max(E-v,1),ye=Math.abs(L)>=Je&&Math.abs(L)/Fe>=t.options.swipeVelocity;(L>=t.options.swipeOffset||ye&&L>0)&&t.viewer.currentIndex!==0?R="prev":(L<=-t.options.swipeOffset||ye&&L<0)&&t.viewer.currentIndex!==de.length-1&&(R="next"),e.onSwipeEnd(R)}else{let R="stay";t.options.swipeBottomToClose&&T>=t.options.swipeOffset?R="close-bottom":t.options.swipeTopToClose&&T<=-t.options.swipeOffset&&(R="close-top"),e.onSwipeEnd(R)}}function F(){b=!1;let a=S,h=y;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let E=z(t);if(!E){e.onPhotoDragEnd(null);return}let g=$(E),L=t.options.swipeOffset*t.viewer.scaleSize,T=0,X=0;if(t.viewer.photoPosX>g.maxX?T=-1:t.viewer.photoPosX<g.minX&&(T=1),t.viewer.photoPosY>g.maxY?X=-1:t.viewer.photoPosY<g.minY&&(X=1),t.viewer.photoPosX-g.maxX>L&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(g.minX-t.viewer.photoPosX>L&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}T===0&&X===0?(C=O/5,N=D/5):oe(T,X),e.onPhotoDragEnd(null)}function _(a){if(o.delete(a.pointerId),H){o.size<2&&f();return}if(b){F();return}s&&I()}function B(...a){for(let h of a)h.addEventListener("pointerdown",le,{signal:i}),h.addEventListener("pointermove",w,{signal:i}),h.addEventListener("pointerup",_,{signal:i}),h.addEventListener("pointercancel",_,{signal:i})}function G(){clearInterval(re),x!==null&&(cancelAnimationFrame(x),x=null)}return{attach:B,detach:G}}function ie(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function be(){let t=document.createElement("button");return t.type="button",t}function et(t){return t.replace(/"/g,'\\"')}function Ge({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let u=document.createElement("dialog");u.className=r.smartPhoto,u.setAttribute("aria-labelledby",`smartphoto-${t}-title`),u.style.display="none",u.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let d=document.createElement("div");d.className=r.smartPhotoInner;let v=document.createElement("div");v.className=r.smartPhotoHeader;let b=document.createElement("span");b.className=r.smartPhotoCount;let y=document.createElement("h1");y.id=`smartphoto-${t}-title`,y.className=r.smartPhotoCaption,y.setAttribute("tabindex","-1");let S=document.createElement("button");S.className=r.smartPhotoDismiss,S.appendChild(ie(s.closeDialog)),S.addEventListener("click",()=>i.onDismiss(),{signal:o}),v.append(b,y,S);let O=document.createElement("div");O.className=r.smartPhotoContent,O.addEventListener("click",m=>{m.target===O&&i.onBackdropClick()},{signal:o});let D=document.createElement("ul");D.className=r.smartPhotoList,D.setAttribute("role","region"),D.setAttribute("aria-roledescription","carousel"),D.setAttribute("aria-label",s.carouselLabel),D.setAttribute("aria-live","polite"),D.setAttribute("aria-atomic","false"),d.append(v,O,D);let H=null,Y=null,x=null;if(e.arrows){H=document.createElement("ul"),H.className=r.smartPhotoArrows,Y=document.createElement("li"),Y.className=r.smartPhotoArrowLeft;let m=be();m.appendChild(ie(s.gotoPrevImage)),m.addEventListener("click",()=>i.onPrev(),{signal:o}),Y.appendChild(m),x=document.createElement("li"),x.className=r.smartPhotoArrowRight;let l=be();l.appendChild(ie(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),x.appendChild(l),H.append(Y,x),d.appendChild(H)}let C=null,N=null;e.nav&&(C=document.createElement("nav"),C.className=r.smartPhotoNav,C.setAttribute("aria-label","Choose slide to display"),N=document.createElement("ul"),C.appendChild(N),d.appendChild(C)),p.appendChild(d),u.appendChild(p),n.appendChild(u);let c={dialog:u,count:b,caption:y,dismiss:S,content:O,list:D,arrows:H,arrowLeft:Y,arrowRight:x,nav:C,navList:N,slides:new Map,imgClone:null};function $(){let m=document.createElement("div");m.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,m.appendChild(l),m}function U(m){var w,f;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let P=document.createElement("img");return P.className=r.smartPhotoImg,P.src=(w=m.src)!=null?w:"",P.alt=(f=m.alt)!=null?f:"",P.addEventListener("dragstart",I=>I.preventDefault(),{signal:o}),l.appendChild(P),{imgWrap:l,img:P}}function oe(m,l){var P;c.list.replaceChildren(),(P=c.navList)==null||P.replaceChildren(),c.slides=new Map,m.forEach(w=>{var F,_;let f=document.createElement("li");f.setAttribute("role","group"),f.setAttribute("aria-roledescription","slide"),f.setAttribute("aria-label",`${w.index+1} of ${m.length}`);let I={li:f,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(w.processed){let{imgWrap:B,img:G}=U(w);f.appendChild(B),I.imgWrap=B,I.img=G}else{let B=$();f.appendChild(B),I.loaderWrap=B}if(c.list.appendChild(f),c.slides.set(w,I),c.navList){let B=document.createElement("li"),G=be();G.style.backgroundImage=`url("${et((F=w.thumb)!=null?F:"")}")`;let a=w.index;G.addEventListener("click",()=>i.onNavigate(a),{signal:o}),G.appendChild(ie(`go to ${(_=w.caption)!=null?_:""}`)),B.appendChild(G),c.navList.appendChild(B),I.navLink=G}}),Q(l)}function re(m,l){var f;if(l.imgWrap||!m.processed)return l;let{imgWrap:P,img:w}=U(m);return(f=l.loaderWrap)==null||f.replaceWith(P),l.loaderWrap=null,l.imgWrap=P,l.img=w,l}function V(m){m&&document.activeElement&&m.contains(document.activeElement)&&c.caption.focus()}function Q(m){let{viewer:l}=m;c.count.textContent=`${l.currentIndex+1}/${l.total}`,c.slides.forEach((P,w)=>{var F;let f=re(w,P),I=w.index===l.currentIndex;f.li.style.transform=`translate(${w.translateX}px,${w.translateY}px)`,f.li.classList.toggle("current",I),I?f.li.removeAttribute("aria-hidden"):f.li.setAttribute("aria-hidden","true"),I&&(c.caption.textContent=(F=w.caption)!=null?F:""),f.imgWrap&&f.img&&(f.imgWrap.style.transform=`translate(${w.x}px,${w.y}px) scale(${w.scale})`,f.img.style.width=`${w.width}px`,f.img.classList.toggle("active",l.appear),f.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),f.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),f.navLink&&(f.navLink.classList.toggle("current",I),I?f.navLink.setAttribute("aria-current","true"):f.navLink.removeAttribute("aria-current"))}),c.arrowLeft&&(l.showPrevArrow?c.arrowLeft.removeAttribute("aria-hidden"):(V(c.arrowLeft),c.arrowLeft.setAttribute("aria-hidden","true"))),c.arrowRight&&(l.showNextArrow?c.arrowRight.removeAttribute("aria-hidden"):(V(c.arrowRight),c.arrowRight.setAttribute("aria-hidden","true"))),c.arrows&&(l.hideUi&&V(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.nav&&(l.hideUi&&V(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ne(m){for(let[l,P]of c.slides)if(l.index===m.viewer.currentIndex)return P;return null}function se(m){let{viewer:l}=m,P=ne(m),w=P==null?void 0:P.img;w&&(w.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,w.classList.toggle(r.smartPhotoImgOnMove,l.scale),w.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),c.nav&&(l.hideUi&&V(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.arrows&&(l.hideUi&&V(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ae(m){let{viewer:l}=m;c.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,c.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function le(m){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=m.img,l.style.width=`${m.width}px`,l.style.height=`${m.height}px`,l.style.transform=`translate(${m.left}px,${m.top}px) scale(1)`,p.appendChild(l),c.imgClone=l}function he(){var m;(m=c.imgClone)==null||m.remove(),c.imgClone=null}function ue(){n.remove()}return{root:n,refs:c,render:Q,syncSlides:oe,updatePhotoTransform:se,updateListTransform:ae,showAppearEffect:le,removeAppearEffect:he,destroy:ue}}var M=Z,W=ee;function tt(t){return t.length>0&&t[0]instanceof Element}function it(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function We(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var K=class{constructor(e,i){this.id=it();this.abortController=new AbortController;this.isSmartPhoneFlag=J();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;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=q(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let r=this.itemsByElement.get(o);r&&this.openPhoto(r,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${W()}px`)};this.handleVisualViewportResize=()=>{this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!A(this.state))&&(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit())};this.handleResize=()=>{A(this.state)&&(this.updateViewportHeight(),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(!A(this.state))return;this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=M(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==M()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25)},25)};o(0)};this.rootSelector=typeof e=="string"?e:null,this.state=He(i!=null?i:{}),this.view=Ge({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Ye({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,r=s=>i.call(o,s);o.addEventListener(e,r,{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){this.state.viewer.currentIndex=Number.parseInt(String(e),10),this.state.viewer.currentIndex||(this.state.viewer.currentIndex=0),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=We();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=z(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=j(e,M(),W(),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.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin")},300)))}zoomOutPhoto(){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.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var p,d,v;let o=(p=i.group)!=null?p:this.state.viewer.currentGroup;if(o===null)return;let r=this.state.groups.get(o);if(!(r!=null&&r.length))return;let s=typeof e=="number"?r[e]:r.find(b=>b.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,u=(v=(d=i.trigger)!=null?d:s.element)!=null?v:n;this.openPhoto(s,u)}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)&&!tt(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,n;let i=q(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=fe(e,this.state.options,o,M());return ve(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=pe(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=ze(e,o,M());return ve(this.state,r),this.loadAllFired.delete(i),r}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(d=>q(d)===e),o=new Set(i),r=(p=this.state.groups.get(e))!=null?p:[],s=new Map;r.forEach(d=>{d.element&&s.set(d.element,d)});let n=i.length!==r.length,u=i.map((d,v)=>{let b=s.get(d);if(b)return b.index!==v&&(n=!0,b.index=v),b;n=!0;let y=fe(d,this.state.options,v,M());return this.itemsByElement.set(d,y),y});return r.forEach(d=>{d.element&&!o.has(d.element)&&this.itemsByElement.delete(d.element)}),ge(u,M()),this.state.groups.set(e,u),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=A(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=We();this.setHash(Ne(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?Ve(this.state,Ce(e)):null}setPosByCurrentIndex(){let e=z(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=A(this.state);e&&De(e,M(),W(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){ge(A(this.state),M())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;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.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=A(this.state);if(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(),we(this.state),this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag){let o=z(this.state);this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=j(o,M(),W(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}openPhotoWithViewTransition(e){var n,u;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(n=e==null?void 0:e.querySelector("img"))!=null?n:null;o&&(o.style.viewTransitionName=i);let r=()=>{o&&(o.style.viewTransitionName="");let p=this.currentImgElement();p&&(p.style.viewTransitionName="")},s=(u=document.startViewTransition)==null?void 0:u.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i});s==null||s.ready.catch(()=>{r()}),s==null||s.finished.then(r,r)}addAppearEffect(e,i){var O;let o=(O=e==null?void 0:e.querySelector("img"))!=null?O:null;if(!o){this.state.viewer.appear=!0;return}let r=Te(o),s=o.offsetWidth,n=o.offsetHeight,u=M(),p=W(),d=p-this.state.options.headerHeight-this.state.options.footerHeight,v=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?v=p/n:v=u/s:(s>=n?i.height<d?v=i.width/s:v=d/n:i.height<d?v=i.height/n:v=d/n,s*v>u&&(v=u/s));let b=(v-1)/2*s+(u-s*v)/2,y=(v-1)/2*n+(p-n*v)/2,S=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:S||i.src||"",afterX:b,afterY:y,scale:v}}runAppearEffect(e){this.view.showAppearEffect(e);let i=this.view.refs.imgClone;return new Promise(o=>{let r=()=>{i.removeEventListener("transitionend",r,!0),o()};i.addEventListener("transitionend",r,!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=M(),i=W();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(M()===e&&W()===i||(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.view.render(this.state)))})}openPhoto(e,i){let o=this.rootSelector?this.resyncGroupFromDom(e.groupId):!1;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=>{let o=this.view.refs.dialog,r=this.currentImgElement(),s=W(),n=e==="top"?`translateY(-${s}px)`:`translateY(${s}px)`,u=()=>{this.finishHideEffect===u&&(this.finishHideEffect=null,o.removeEventListener("transitionend",u,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=u,r&&(r.style.transform=n),o.addEventListener("transitionend",u,!0),this.scheduleTimeout(u,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;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=(r=e.src)!=null?r:""})}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=A(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).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=z(this.state);this.state.viewer.onMove=!1,we(this.state),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(r=>r!==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",Ae(o))}fireEvent(e){Le(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:()=>this.zoomPhoto(),onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},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 ot=K;return qe(rt);})();
7
7
  SmartPhoto = SmartPhoto.default;
package/lib/smartphoto.js CHANGED
@@ -73,6 +73,16 @@ var parseQuery = (query) => {
73
73
  }
74
74
  return data;
75
75
  };
76
+ var getWindowWidth = () => {
77
+ return document.documentElement.clientWidth;
78
+ };
79
+ var getWindowHeight = () => {
80
+ const visualViewport = window.visualViewport;
81
+ if (visualViewport) {
82
+ return visualViewport.height * visualViewport.scale;
83
+ }
84
+ return document.documentElement.clientHeight;
85
+ };
76
86
  var getViewPos = (element) => {
77
87
  return {
78
88
  left: element.getBoundingClientRect().left,
@@ -427,8 +437,8 @@ function getForceAndTheta(x, y) {
427
437
  }
428
438
  function windowSize() {
429
439
  return {
430
- width: document.documentElement.clientWidth,
431
- height: document.documentElement.clientHeight
440
+ width: getWindowWidth(),
441
+ height: getWindowHeight()
432
442
  };
433
443
  }
434
444
  function createGestures({ state, callbacks }, { signal }) {
@@ -1147,16 +1157,8 @@ function createView({ id, options }, handlers, { signal }) {
1147
1157
  }
1148
1158
 
1149
1159
  // src/core/index.ts
1150
- function getWindowWidth() {
1151
- return document.documentElement.clientWidth;
1152
- }
1153
- function getWindowHeight() {
1154
- const visualViewport = window.visualViewport;
1155
- if (visualViewport) {
1156
- return visualViewport.height * visualViewport.scale;
1157
- }
1158
- return document.documentElement.clientHeight;
1159
- }
1160
+ var getWindowWidth2 = getWindowWidth;
1161
+ var getWindowHeight2 = getWindowHeight;
1160
1162
  function isElementArray(source) {
1161
1163
  return source.length > 0 && source[0] instanceof Element;
1162
1164
  }
@@ -1227,7 +1229,7 @@ var SmartPhoto = class {
1227
1229
  this.updateViewportHeight = () => {
1228
1230
  this.view.refs.dialog.style.setProperty(
1229
1231
  "--smartphoto-vh",
1230
- `${getWindowHeight()}px`
1232
+ `${getWindowHeight2()}px`
1231
1233
  );
1232
1234
  };
1233
1235
  // iOS Safari 等ではアドレスバーの表示/非表示に伴う visualViewport の変化が
@@ -1279,11 +1281,11 @@ var SmartPhoto = class {
1279
1281
  this.setHashByCurrentIndex();
1280
1282
  this.setSizeByScreen();
1281
1283
  this.commit();
1282
- const prevWidth = getWindowWidth();
1284
+ const prevWidth = getWindowWidth2();
1283
1285
  const timeout = 500;
1284
1286
  const poll = (time) => {
1285
1287
  this.scheduleTimeout(() => {
1286
- if (prevWidth !== getWindowWidth()) {
1288
+ if (prevWidth !== getWindowWidth2()) {
1287
1289
  this.updateViewportHeight();
1288
1290
  this.resetTranslateCurrent();
1289
1291
  this.setPosByCurrentIndex();
@@ -1423,8 +1425,8 @@ var SmartPhoto = class {
1423
1425
  this.state.viewer.hideUi = true;
1424
1426
  this.state.viewer.scaleSize = scaleBorder(
1425
1427
  item,
1426
- getWindowWidth(),
1427
- getWindowHeight(),
1428
+ getWindowWidth2(),
1429
+ getWindowHeight2(),
1428
1430
  this.isSmartPhoneFlag
1429
1431
  );
1430
1432
  if (this.state.viewer.scaleSize <= 1) {
@@ -1512,7 +1514,7 @@ var SmartPhoto = class {
1512
1514
  element,
1513
1515
  this.state.options,
1514
1516
  index,
1515
- getWindowWidth()
1517
+ getWindowWidth2()
1516
1518
  );
1517
1519
  addItemToGroup(this.state, item);
1518
1520
  this.loadAllFired.delete(groupId);
@@ -1522,7 +1524,7 @@ var SmartPhoto = class {
1522
1524
  addSlideItem(slide) {
1523
1525
  const groupId = groupIdFromSlide(slide);
1524
1526
  const index = this.state.groups.get(groupId)?.length ?? 0;
1525
- const item = itemFromSlide(slide, index, getWindowWidth());
1527
+ const item = itemFromSlide(slide, index, getWindowWidth2());
1526
1528
  addItemToGroup(this.state, item);
1527
1529
  this.loadAllFired.delete(groupId);
1528
1530
  return item;
@@ -1577,7 +1579,7 @@ var SmartPhoto = class {
1577
1579
  el,
1578
1580
  this.state.options,
1579
1581
  index,
1580
- getWindowWidth()
1582
+ getWindowWidth2()
1581
1583
  );
1582
1584
  this.itemsByElement.set(el, item);
1583
1585
  return item;
@@ -1587,7 +1589,7 @@ var SmartPhoto = class {
1587
1589
  this.itemsByElement.delete(it.element);
1588
1590
  }
1589
1591
  });
1590
- resetTranslate(rebuilt, getWindowWidth());
1592
+ resetTranslate(rebuilt, getWindowWidth2());
1591
1593
  this.state.groups.set(groupId, rebuilt);
1592
1594
  if (changed) {
1593
1595
  this.loadAllFired.delete(groupId);
@@ -1638,15 +1640,15 @@ var SmartPhoto = class {
1638
1640
  }
1639
1641
  sizeItems(
1640
1642
  items,
1641
- getWindowWidth(),
1642
- getWindowHeight(),
1643
+ getWindowWidth2(),
1644
+ getWindowHeight2(),
1643
1645
  this.state.options.headerHeight,
1644
1646
  this.state.options.footerHeight
1645
1647
  );
1646
1648
  }
1647
1649
  // resize/orientationchange ハンドラは呼び出し前に currentItems の存在を確認済み
1648
1650
  resetTranslateCurrent() {
1649
- resetTranslate(currentItems(this.state), getWindowWidth());
1651
+ resetTranslate(currentItems(this.state), getWindowWidth2());
1650
1652
  }
1651
1653
  currentImgElement() {
1652
1654
  for (const [item, slideRefs] of this.view.refs.slides) {
@@ -1693,8 +1695,8 @@ var SmartPhoto = class {
1693
1695
  this.state.viewer.hideUi = true;
1694
1696
  this.state.viewer.scaleSize = scaleBorder(
1695
1697
  item,
1696
- getWindowWidth(),
1697
- getWindowHeight(),
1698
+ getWindowWidth2(),
1699
+ getWindowHeight2(),
1698
1700
  this.isSmartPhoneFlag
1699
1701
  );
1700
1702
  }
@@ -1745,8 +1747,8 @@ var SmartPhoto = class {
1745
1747
  const pos = getViewPos(img);
1746
1748
  const width = img.offsetWidth;
1747
1749
  const height = img.offsetHeight;
1748
- const toX = getWindowWidth();
1749
- const toY = getWindowHeight();
1750
+ const toX = getWindowWidth2();
1751
+ const toY = getWindowHeight2();
1750
1752
  const screenY = toY - this.state.options.headerHeight - this.state.options.footerHeight;
1751
1753
  let scale = 1;
1752
1754
  if (this.state.options.resizeStyle === "fill" && this.isSmartPhoneFlag) {
@@ -1833,13 +1835,13 @@ var SmartPhoto = class {
1833
1835
  // dialog が開いてスクロールバーが消えた後の幅とズレる。次の描画フレームで
1834
1836
  // 開いた後の正しいサイズを使って再計算し、必要なら再描画する
1835
1837
  resyncSizeAfterOpen() {
1836
- const winWidthBefore = getWindowWidth();
1837
- const winHeightBefore = getWindowHeight();
1838
+ const winWidthBefore = getWindowWidth2();
1839
+ const winHeightBefore = getWindowHeight2();
1838
1840
  requestAnimationFrame(() => {
1839
1841
  if (!this.state.viewer.isOpen) {
1840
1842
  return;
1841
1843
  }
1842
- if (getWindowWidth() === winWidthBefore && getWindowHeight() === winHeightBefore) {
1844
+ if (getWindowWidth2() === winWidthBefore && getWindowHeight2() === winHeightBefore) {
1843
1845
  return;
1844
1846
  }
1845
1847
  this.resetTranslateCurrent();
@@ -1869,7 +1871,7 @@ var SmartPhoto = class {
1869
1871
  return new Promise((resolve) => {
1870
1872
  const dialog = this.view.refs.dialog;
1871
1873
  const img = this.currentImgElement();
1872
- const height = getWindowHeight();
1874
+ const height = getWindowHeight2();
1873
1875
  const applied = dir === "top" ? `translateY(-${height}px)` : `translateY(${height}px)`;
1874
1876
  const finish = () => {
1875
1877
  if (this.finishHideEffect !== finish) {
@@ -1931,6 +1933,9 @@ var SmartPhoto = class {
1931
1933
  }
1932
1934
  if (promises.length) {
1933
1935
  Promise.all(promises).then(() => {
1936
+ if (!this.state.viewer.isOpen) {
1937
+ return;
1938
+ }
1934
1939
  this.initPhoto();
1935
1940
  this.commit();
1936
1941
  });
@@ -1960,6 +1965,9 @@ var SmartPhoto = class {
1960
1965
  this.loadNeighborItems();
1961
1966
  if (item && !item.loaded) {
1962
1967
  this.loadItem(item).then(() => {
1968
+ if (!this.state.viewer.isOpen) {
1969
+ return;
1970
+ }
1963
1971
  this.initPhoto();
1964
1972
  this.commit();
1965
1973
  });
@@ -47,6 +47,16 @@ var parseQuery = (query) => {
47
47
  }
48
48
  return data;
49
49
  };
50
+ var getWindowWidth = () => {
51
+ return document.documentElement.clientWidth;
52
+ };
53
+ var getWindowHeight = () => {
54
+ const visualViewport = window.visualViewport;
55
+ if (visualViewport) {
56
+ return visualViewport.height * visualViewport.scale;
57
+ }
58
+ return document.documentElement.clientHeight;
59
+ };
50
60
  var getViewPos = (element) => {
51
61
  return {
52
62
  left: element.getBoundingClientRect().left,
@@ -401,8 +411,8 @@ function getForceAndTheta(x, y) {
401
411
  }
402
412
  function windowSize() {
403
413
  return {
404
- width: document.documentElement.clientWidth,
405
- height: document.documentElement.clientHeight
414
+ width: getWindowWidth(),
415
+ height: getWindowHeight()
406
416
  };
407
417
  }
408
418
  function createGestures({ state, callbacks }, { signal }) {
@@ -1121,16 +1131,8 @@ function createView({ id, options }, handlers, { signal }) {
1121
1131
  }
1122
1132
 
1123
1133
  // src/core/index.ts
1124
- function getWindowWidth() {
1125
- return document.documentElement.clientWidth;
1126
- }
1127
- function getWindowHeight() {
1128
- const visualViewport = window.visualViewport;
1129
- if (visualViewport) {
1130
- return visualViewport.height * visualViewport.scale;
1131
- }
1132
- return document.documentElement.clientHeight;
1133
- }
1134
+ var getWindowWidth2 = getWindowWidth;
1135
+ var getWindowHeight2 = getWindowHeight;
1134
1136
  function isElementArray(source) {
1135
1137
  return source.length > 0 && source[0] instanceof Element;
1136
1138
  }
@@ -1201,7 +1203,7 @@ var SmartPhoto = class {
1201
1203
  this.updateViewportHeight = () => {
1202
1204
  this.view.refs.dialog.style.setProperty(
1203
1205
  "--smartphoto-vh",
1204
- `${getWindowHeight()}px`
1206
+ `${getWindowHeight2()}px`
1205
1207
  );
1206
1208
  };
1207
1209
  // iOS Safari 等ではアドレスバーの表示/非表示に伴う visualViewport の変化が
@@ -1253,11 +1255,11 @@ var SmartPhoto = class {
1253
1255
  this.setHashByCurrentIndex();
1254
1256
  this.setSizeByScreen();
1255
1257
  this.commit();
1256
- const prevWidth = getWindowWidth();
1258
+ const prevWidth = getWindowWidth2();
1257
1259
  const timeout = 500;
1258
1260
  const poll = (time) => {
1259
1261
  this.scheduleTimeout(() => {
1260
- if (prevWidth !== getWindowWidth()) {
1262
+ if (prevWidth !== getWindowWidth2()) {
1261
1263
  this.updateViewportHeight();
1262
1264
  this.resetTranslateCurrent();
1263
1265
  this.setPosByCurrentIndex();
@@ -1397,8 +1399,8 @@ var SmartPhoto = class {
1397
1399
  this.state.viewer.hideUi = true;
1398
1400
  this.state.viewer.scaleSize = scaleBorder(
1399
1401
  item,
1400
- getWindowWidth(),
1401
- getWindowHeight(),
1402
+ getWindowWidth2(),
1403
+ getWindowHeight2(),
1402
1404
  this.isSmartPhoneFlag
1403
1405
  );
1404
1406
  if (this.state.viewer.scaleSize <= 1) {
@@ -1486,7 +1488,7 @@ var SmartPhoto = class {
1486
1488
  element,
1487
1489
  this.state.options,
1488
1490
  index,
1489
- getWindowWidth()
1491
+ getWindowWidth2()
1490
1492
  );
1491
1493
  addItemToGroup(this.state, item);
1492
1494
  this.loadAllFired.delete(groupId);
@@ -1496,7 +1498,7 @@ var SmartPhoto = class {
1496
1498
  addSlideItem(slide) {
1497
1499
  const groupId = groupIdFromSlide(slide);
1498
1500
  const index = this.state.groups.get(groupId)?.length ?? 0;
1499
- const item = itemFromSlide(slide, index, getWindowWidth());
1501
+ const item = itemFromSlide(slide, index, getWindowWidth2());
1500
1502
  addItemToGroup(this.state, item);
1501
1503
  this.loadAllFired.delete(groupId);
1502
1504
  return item;
@@ -1551,7 +1553,7 @@ var SmartPhoto = class {
1551
1553
  el,
1552
1554
  this.state.options,
1553
1555
  index,
1554
- getWindowWidth()
1556
+ getWindowWidth2()
1555
1557
  );
1556
1558
  this.itemsByElement.set(el, item);
1557
1559
  return item;
@@ -1561,7 +1563,7 @@ var SmartPhoto = class {
1561
1563
  this.itemsByElement.delete(it.element);
1562
1564
  }
1563
1565
  });
1564
- resetTranslate(rebuilt, getWindowWidth());
1566
+ resetTranslate(rebuilt, getWindowWidth2());
1565
1567
  this.state.groups.set(groupId, rebuilt);
1566
1568
  if (changed) {
1567
1569
  this.loadAllFired.delete(groupId);
@@ -1612,15 +1614,15 @@ var SmartPhoto = class {
1612
1614
  }
1613
1615
  sizeItems(
1614
1616
  items,
1615
- getWindowWidth(),
1616
- getWindowHeight(),
1617
+ getWindowWidth2(),
1618
+ getWindowHeight2(),
1617
1619
  this.state.options.headerHeight,
1618
1620
  this.state.options.footerHeight
1619
1621
  );
1620
1622
  }
1621
1623
  // resize/orientationchange ハンドラは呼び出し前に currentItems の存在を確認済み
1622
1624
  resetTranslateCurrent() {
1623
- resetTranslate(currentItems(this.state), getWindowWidth());
1625
+ resetTranslate(currentItems(this.state), getWindowWidth2());
1624
1626
  }
1625
1627
  currentImgElement() {
1626
1628
  for (const [item, slideRefs] of this.view.refs.slides) {
@@ -1667,8 +1669,8 @@ var SmartPhoto = class {
1667
1669
  this.state.viewer.hideUi = true;
1668
1670
  this.state.viewer.scaleSize = scaleBorder(
1669
1671
  item,
1670
- getWindowWidth(),
1671
- getWindowHeight(),
1672
+ getWindowWidth2(),
1673
+ getWindowHeight2(),
1672
1674
  this.isSmartPhoneFlag
1673
1675
  );
1674
1676
  }
@@ -1719,8 +1721,8 @@ var SmartPhoto = class {
1719
1721
  const pos = getViewPos(img);
1720
1722
  const width = img.offsetWidth;
1721
1723
  const height = img.offsetHeight;
1722
- const toX = getWindowWidth();
1723
- const toY = getWindowHeight();
1724
+ const toX = getWindowWidth2();
1725
+ const toY = getWindowHeight2();
1724
1726
  const screenY = toY - this.state.options.headerHeight - this.state.options.footerHeight;
1725
1727
  let scale = 1;
1726
1728
  if (this.state.options.resizeStyle === "fill" && this.isSmartPhoneFlag) {
@@ -1807,13 +1809,13 @@ var SmartPhoto = class {
1807
1809
  // dialog が開いてスクロールバーが消えた後の幅とズレる。次の描画フレームで
1808
1810
  // 開いた後の正しいサイズを使って再計算し、必要なら再描画する
1809
1811
  resyncSizeAfterOpen() {
1810
- const winWidthBefore = getWindowWidth();
1811
- const winHeightBefore = getWindowHeight();
1812
+ const winWidthBefore = getWindowWidth2();
1813
+ const winHeightBefore = getWindowHeight2();
1812
1814
  requestAnimationFrame(() => {
1813
1815
  if (!this.state.viewer.isOpen) {
1814
1816
  return;
1815
1817
  }
1816
- if (getWindowWidth() === winWidthBefore && getWindowHeight() === winHeightBefore) {
1818
+ if (getWindowWidth2() === winWidthBefore && getWindowHeight2() === winHeightBefore) {
1817
1819
  return;
1818
1820
  }
1819
1821
  this.resetTranslateCurrent();
@@ -1843,7 +1845,7 @@ var SmartPhoto = class {
1843
1845
  return new Promise((resolve) => {
1844
1846
  const dialog = this.view.refs.dialog;
1845
1847
  const img = this.currentImgElement();
1846
- const height = getWindowHeight();
1848
+ const height = getWindowHeight2();
1847
1849
  const applied = dir === "top" ? `translateY(-${height}px)` : `translateY(${height}px)`;
1848
1850
  const finish = () => {
1849
1851
  if (this.finishHideEffect !== finish) {
@@ -1905,6 +1907,9 @@ var SmartPhoto = class {
1905
1907
  }
1906
1908
  if (promises.length) {
1907
1909
  Promise.all(promises).then(() => {
1910
+ if (!this.state.viewer.isOpen) {
1911
+ return;
1912
+ }
1908
1913
  this.initPhoto();
1909
1914
  this.commit();
1910
1915
  });
@@ -1934,6 +1939,9 @@ var SmartPhoto = class {
1934
1939
  this.loadNeighborItems();
1935
1940
  if (item && !item.loaded) {
1936
1941
  this.loadItem(item).then(() => {
1942
+ if (!this.state.viewer.isOpen) {
1943
+ return;
1944
+ }
1937
1945
  this.initPhoto();
1938
1946
  this.commit();
1939
1947
  });
@@ -3,6 +3,8 @@ declare function deepExtend(out: Record<string, unknown>, ...args: unknown[]): R
3
3
  export declare const extend: typeof deepExtend;
4
4
  export declare const triggerEvent: (el: Element, eventName: string, options?: unknown) => void;
5
5
  export declare const parseQuery: (query: string) => Record<string, string>;
6
+ export declare const getWindowWidth: () => number;
7
+ export declare const getWindowHeight: () => number;
6
8
  export declare const getViewPos: (element: Element) => {
7
9
  left: number;
8
10
  top: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smartphoto",
3
- "version": "2.1.9",
3
+ "version": "2.1.11",
4
4
  "description": "smartphoto",
5
5
  "homepage": "https://developer.a-blogcms.jp",
6
6
  "main": "./lib/smartphoto.js",