smartphoto 2.1.0 → 2.1.2

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.
package/README.md CHANGED
@@ -357,37 +357,41 @@ photo.on('zoomout',function(){
357
357
  </tr>
358
358
  </table>
359
359
 
360
- ### SCSS
360
+ ### CSS Custom Properties
361
361
 
362
362
  <table>
363
363
  <tr>
364
- <th>variable</th>
364
+ <th>property</th>
365
365
  <th>description</th>
366
366
  <th>default</th>
367
367
  </tr>
368
368
  <tr>
369
- <td>$animation-speed</td>
370
- <td>animation speed when switching images</td>
371
- <td>.3s</td>
369
+ <td>--smartphoto-animation-speed</td>
370
+ <td>animation speed when switching/opening/closing images. Overridden per-instance by the <code>animationSpeed</code> JS option</td>
371
+ <td>300ms</td>
372
+ </tr>
373
+ <tr>
374
+ <td>--smartphoto-animation-function</td>
375
+ <td>easing function used for animations</td>
376
+ <td>ease-out</td>
372
377
  </tr>
373
378
  <tr>
374
- <td>$backdrop-color</td>
379
+ <td>--smartphoto-backdrop-color</td>
375
380
  <td>backdrop color when viewing images</td>
376
381
  <td>rgba(0, 0, 0, 1)</td>
377
382
  </tr>
378
383
  <tr>
379
- <td>$header-color</td>
384
+ <td>--smartphoto-header-color</td>
380
385
  <td>header color</td>
381
386
  <td>rgba(0, 0, 0, .2)</td>
382
387
  </tr>
383
388
  </table>
384
389
 
385
- `$animation-speed` is the SCSS build-time default. At runtime it is overridden per-instance by the `animationSpeed` JS option via the `--smartphoto-animation-speed` CSS custom property set on the `dialog` element.
386
-
387
- Every SCSS variable above is also exposed as a CSS custom property (`--smartphoto-animation-speed`, `--smartphoto-animation-function`, `--smartphoto-backdrop-color`, `--smartphoto-header-color`), so they can be overridden without recompiling SCSS, e.g.:
390
+ Set these on `.smartphoto` (or `:root`) to override the defaults, no rebuild required:
388
391
 
389
392
  ```css
390
393
  .smartphoto {
394
+ --smartphoto-animation-speed: 500ms;
391
395
  --smartphoto-animation-function: ease-in-out;
392
396
  --smartphoto-backdrop-color: rgba(0, 0, 0, 0.9);
393
397
  --smartphoto-header-color: rgba(0, 0, 0, 0.4);
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * SmartPhoto v2.1.0
2
+ * SmartPhoto v2.1.2
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
@@ -1077,6 +1077,9 @@
1077
1077
  function getWindowHeight() {
1078
1078
  return document.documentElement.clientHeight;
1079
1079
  }
1080
+ function isElementArray(source) {
1081
+ return source.length > 0 && source[0] instanceof Element;
1082
+ }
1080
1083
  function getUniqId() {
1081
1084
  return (Date.now().toString(36) + Math.random().toString(36).substring(2, 7)).toUpperCase();
1082
1085
  }
@@ -1337,7 +1340,7 @@
1337
1340
  }
1338
1341
  // ---- 内部: ソース取り込み ----
1339
1342
  ingestSource(source) {
1340
- if (Array.isArray(source)) {
1343
+ if (Array.isArray(source) && !isElementArray(source)) {
1341
1344
  source.forEach((slide) => {
1342
1345
  this.addSlideItem(slide);
1343
1346
  });
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * SmartPhoto v2.1.0
2
+ * SmartPhoto v2.1.2
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
6
- "use strict";(()=>{var j=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};function fe(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]=fe((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var ve=fe,ne=(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)},we=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},ge=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var Xe={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,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:300};function Ee(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Ee(i)}),Object.freeze(t)}function Pe(t){return{options:Ee(ve({},Xe,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 ae(t){return t.getAttribute("data-group")||"nogroup"}function le(t){return t.group||"nogroup"}function be(t,e,i,o){let r=ae(t),s=t.getAttribute("href"),n=t.querySelector("img"),c=s;n&&(n.getAttribute(e.lazyAttribute)?c=n.getAttribute(e.lazyAttribute):n.currentSrc?c=n.currentSrc:c=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 E=t.getAttribute("data-id");return{src:s,thumb:c,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:E||i,loaded:!1,processed:!1,element:t}}function ye(t,e,i){var E,v,x,b,I;let o=le(t),r=t.src,s=(E=t.thumb)!=null?E:r,n=(v=t.caption)!=null?v:null,c=(b=(x=t.alt)!=null?x:n)!=null?b:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:c,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:(I=t.id)!=null?I:e,loaded:p,processed:!1,element:null}}function he(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 H(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function M(t){var i;let e=H(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function ue(t){let e=H(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 Se(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function Q(t,e){let i=10**e;return Math.round(t*i)/i}function V(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function xe(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,c,p,E;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(E=(o-s)/2,c=-1*E):(E=(s-o)/2,c=-1*E),{minX:Q(n,6)*e.scaleSize,minY:Q(c,6)*e.scaleSize,maxX:Q(p,6)*e.scaleSize,maxY:Q(E,6)*e.scaleSize}}function Ie(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 Le(t){let e=M(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function Te(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 de(t,e){let i=10**e;return Math.round(t*i)/i}function W(t){return{x:t.pageX,y:t.pageY}}function Ce(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}function Ye(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ae(){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}function He({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,c=null,p=null,E=null,v=!1,x=null,b=null,I=0,z=0,y=!1,Y=0,L=0,T=0;function N(){return j()}function D(a){let{width:h,height:f}=Ae();return xe(a,t.viewer,h,f)}function u(a){let{width:h,height:f}=Ae();return V(a,h,f,N())}function J(a,h){let f=M(t),m=D(f);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=m.minX:a===-1&&(t.viewer.photoPosX=m.maxX),h===1?t.viewer.photoPosY=m.minY:h===-1&&(t.viewer.photoPosY=m.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let R=setInterval(()=>{if(y||s||v||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=L,t.viewer.photoPosY+=T;let a=M(t);if(!a)return;let h=D(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,L*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,L*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,T*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,T*=-.2);let f=Ye(L,T),m=f.force-t.options.registance;Math.abs(m)<.5||(L=Math.cos(f.theta)*m,T=Math.sin(f.theta)*m,e.onPhotoDragMove())},t.options.forceInterval);function $(a,h){(a>5||a<-5)&&(L+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(T+=h*.05)}function K(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||y||s||v||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?$(a.gamma,a.beta):h===90?$(a.beta,a.gamma):h===-90?$(-a.beta,-a.gamma):h===180&&$(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",K,{signal:i});function B(){y=!0,s=!1,v=!1;let a=Array.from(o.values());Y=Ce(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function U(a){let h=W(a);s=!0,n=!0,c=h,p=h}function _(a){v=!0;let h=W(a);b=h,x=h}function Z(a){var h,f;try{(f=(h=a.currentTarget).setPointerCapture)==null||f.call(h,a.pointerId)}catch(m){}if(o.set(a.pointerId,W(a)),o.size>1){B();return}if(t.viewer.scale){_(a);return}U(a)}function ee(){let a=Array.from(o.values()),h=Ce(a[0],a[1]),f=(h-Y)/100,m=t.viewer.scaleSize,C=t.viewer.photoPosX,A=t.viewer.photoPosY;t.viewer.scaleSize+=de(f,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<m&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-m)*C,t.viewer.photoPosY=(1+t.viewer.scaleSize-m)*A);let X=M(t);if(X){let re=u(X);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>re}Y=h,e.onGestureMove()}function te(a){let h=W(a),f=h.x-p.x,m=h.y-c.y;n&&(e.onSwipeStart(),n=!1,E=Math.abs(f)>Math.abs(m)?"horizontal":"vertical"),E==="horizontal"?t.viewer.translateX+=f:t.viewer.translateY=m,p=h,e.onSwipeMove()}function ie(a){let h=W(a),f=h.x-b.x,m=h.y-b.y,C=de(t.viewer.scaleSize*f,6),A=de(t.viewer.scaleSize*m,6);t.viewer.photoPosX+=C,I=C,t.viewer.photoPosY+=A,z=A,b=h,e.onPhotoDragMove()}function oe(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,W(a)),y){ee();return}if(v){ie(a);return}te(a)}}function d(){y=!1;let a=M(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 l(){var pe;s=!1;let a=c,h=p,f=Date.now(),m=r-f,C=h.x-a.x,A=h.y-a.y,X=C===0&&A===0;if(!N()&&X){e.onTap();return}if(Math.abs(m)<=500&&X){e.onTap();return}r=f;let re=(pe=H(t))!=null?pe:[];if(E==="horizontal"){let k="stay";C>=t.options.swipeOffset&&t.viewer.currentIndex!==0?k="prev":C<=-t.options.swipeOffset&&t.viewer.currentIndex!==re.length-1&&(k="next"),e.onSwipeEnd(k)}else{let k="stay";t.options.swipeBottomToClose&&A>=t.options.swipeOffset?k="close-bottom":t.options.swipeTopToClose&&A<=-t.options.swipeOffset&&(k="close-top"),e.onSwipeEnd(k)}}function P(){v=!1;let a=b,h=x;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let f=M(t);if(!f){e.onPhotoDragEnd(null);return}let m=D(f),C=t.options.swipeOffset*t.viewer.scaleSize,A=0,X=0;if(t.viewer.photoPosX>m.maxX?A=-1:t.viewer.photoPosX<m.minX&&(A=1),t.viewer.photoPosY>m.maxY?X=-1:t.viewer.photoPosY<m.minY&&(X=1),t.viewer.photoPosX-m.maxX>C&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(m.minX-t.viewer.photoPosX>C&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}A===0&&X===0?(L=I/5,T=z/5):J(A,X),e.onPhotoDragEnd(null)}function g(a){if(o.delete(a.pointerId),y){o.size<2&&d();return}if(v){P();return}s&&l()}function w(...a){for(let h of a)h.addEventListener("pointerdown",Z,{signal:i}),h.addEventListener("pointermove",oe,{signal:i}),h.addEventListener("pointerup",g,{signal:i}),h.addEventListener("pointercancel",g,{signal:i})}function S(){clearInterval(R)}return{attach:w,detach:S}}function q(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function ce(){let t=document.createElement("button");return t.type="button",t}function Ne(t){return t.replace(/"/g,'\\"')}function Me({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let c=document.createElement("dialog");c.className=r.smartPhoto,c.setAttribute("aria-labelledby",`smartphoto-${t}-title`),c.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let E=document.createElement("div");E.className=r.smartPhotoInner;let v=document.createElement("div");v.className=r.smartPhotoHeader;let x=document.createElement("span");x.className=r.smartPhotoCount;let b=document.createElement("h1");b.id=`smartphoto-${t}-title`,b.className=r.smartPhotoCaption,b.setAttribute("tabindex","-1");let I=document.createElement("button");I.className=r.smartPhotoDismiss,I.appendChild(q(s.closeDialog)),I.addEventListener("click",()=>i.onDismiss(),{signal:o}),v.append(x,b,I);let z=document.createElement("div");z.className=r.smartPhotoContent,z.addEventListener("click",d=>{d.target===z&&i.onBackdropClick()},{signal:o});let y=document.createElement("ul");y.className=r.smartPhotoList,y.setAttribute("role","region"),y.setAttribute("aria-roledescription","carousel"),y.setAttribute("aria-label",s.carouselLabel),y.setAttribute("aria-live","polite"),y.setAttribute("aria-atomic","false"),E.append(v,z,y);let Y=null,L=null,T=null;if(e.arrows){Y=document.createElement("ul"),Y.className=r.smartPhotoArrows,L=document.createElement("li"),L.className=r.smartPhotoArrowLeft;let d=ce();d.appendChild(q(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),L.appendChild(d),T=document.createElement("li"),T.className=r.smartPhotoArrowRight;let l=ce();l.appendChild(q(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),T.appendChild(l),Y.append(L,T),E.appendChild(Y)}let N=null,D=null;e.nav&&(N=document.createElement("nav"),N.className=r.smartPhotoNav,N.setAttribute("aria-label","Choose slide to display"),D=document.createElement("ul"),N.appendChild(D),E.appendChild(N)),p.appendChild(E),c.appendChild(p),n.appendChild(c);let u={dialog:c,count:x,caption:b,dismiss:I,content:z,list:y,arrows:Y,arrowLeft:L,arrowRight:T,nav:N,navList:D,slides:new Map,imgClone:null};function J(){let d=document.createElement("div");d.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,d.appendChild(l),d}function R(d){var g,w;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let P=document.createElement("img");return P.className=r.smartPhotoImg,P.src=(g=d.src)!=null?g:"",P.alt=(w=d.alt)!=null?w:"",P.addEventListener("dragstart",S=>S.preventDefault(),{signal:o}),l.appendChild(P),{imgWrap:l,img:P}}function $(d,l){var P;u.list.replaceChildren(),(P=u.navList)==null||P.replaceChildren(),u.slides=new Map,d.forEach(g=>{var a,h;let w=document.createElement("li");w.setAttribute("role","group"),w.setAttribute("aria-roledescription","slide"),w.setAttribute("aria-label",`${g.index+1} of ${d.length}`);let S={li:w,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(g.processed){let{imgWrap:f,img:m}=R(g);w.appendChild(f),S.imgWrap=f,S.img=m}else{let f=J();w.appendChild(f),S.loaderWrap=f}if(u.list.appendChild(w),u.slides.set(g,S),u.navList){let f=document.createElement("li"),m=ce();m.style.backgroundImage=`url("${Ne((a=g.thumb)!=null?a:"")}")`;let C=g.index;m.addEventListener("click",()=>i.onNavigate(C),{signal:o}),m.appendChild(q(`go to ${(h=g.caption)!=null?h:""}`)),f.appendChild(m),u.navList.appendChild(f),S.navLink=m}}),U(l)}function K(d,l){var w;if(l.imgWrap||!d.processed)return l;let{imgWrap:P,img:g}=R(d);return(w=l.loaderWrap)==null||w.replaceWith(P),l.loaderWrap=null,l.imgWrap=P,l.img=g,l}function B(d){d&&document.activeElement&&d.contains(document.activeElement)&&u.caption.focus()}function U(d){let{viewer:l}=d;u.count.textContent=`${l.currentIndex+1}/${l.total}`,u.slides.forEach((P,g)=>{var a;let w=K(g,P),S=g.index===l.currentIndex;w.li.style.transform=`translate(${g.translateX}px,${g.translateY}px)`,w.li.classList.toggle("current",S),S?w.li.removeAttribute("aria-hidden"):w.li.setAttribute("aria-hidden","true"),S&&(u.caption.textContent=(a=g.caption)!=null?a:""),w.imgWrap&&w.img&&(w.imgWrap.style.transform=`translate(${g.x}px,${g.y}px) scale(${g.scale})`,w.img.style.width=`${g.width}px`,w.img.classList.toggle("active",l.appear),w.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),w.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),w.navLink&&(w.navLink.classList.toggle("current",S),S?w.navLink.setAttribute("aria-current","true"):w.navLink.removeAttribute("aria-current"))}),u.arrowLeft&&(l.showPrevArrow?u.arrowLeft.removeAttribute("aria-hidden"):(B(u.arrowLeft),u.arrowLeft.setAttribute("aria-hidden","true"))),u.arrowRight&&(l.showNextArrow?u.arrowRight.removeAttribute("aria-hidden"):(B(u.arrowRight),u.arrowRight.setAttribute("aria-hidden","true"))),u.arrows&&(l.hideUi&&B(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.nav&&(l.hideUi&&B(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function _(d){for(let[l,P]of u.slides)if(l.index===d.viewer.currentIndex)return P;return null}function Z(d){let{viewer:l}=d,P=_(d),g=P==null?void 0:P.img;g&&(g.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,g.classList.toggle(r.smartPhotoImgOnMove,l.scale),g.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),u.nav&&(l.hideUi&&B(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.arrows&&(l.hideUi&&B(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ee(d){let{viewer:l}=d;u.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,u.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function te(d){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=d.img,l.style.width=`${d.width}px`,l.style.height=`${d.height}px`,l.style.transform=`translate(${d.left}px,${d.top}px) scale(1)`,p.appendChild(l),u.imgClone=l}function ie(){var d;(d=u.imgClone)==null||d.remove(),u.imgClone=null}function oe(){n.remove()}return{root:n,refs:u,render:U,syncSlides:$,updatePhotoTransform:Z,updateListTransform:ee,showAppearEffect:te,removeAppearEffect:ie,destroy:oe}}function O(){return document.documentElement.clientWidth}function G(){return document.documentElement.clientHeight}function Be(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function ze(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var F=class{constructor(e,i){this.id=Be();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.handleResize=()=>{H(this.state)&&(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(!H(this.state))return;this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=O(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==O()?(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25)},25)};o(0)};this.state=Pe(i!=null?i:{}),this.view=Me({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=He({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}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&(o.element?ne(o.element,"click"):this.openPhoto(o,null)),!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.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=ze();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=M(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=V(e,O(),G(),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,E,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(x=>x.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,c=(v=(E=i.trigger)!=null?E:s.element)!=null?v:n;this.openPhoto(s,c)}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 Element?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(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=ae(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=be(e,this.state.options,o,O());return he(this.state,r),this.loadAllFired.delete(i),this.bindThumbnailClick(e,r),r}addSlideItem(e){var s,n;let i=le(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=ye(e,o,O());return he(this.state,r),this.loadAllFired.delete(i),r}bindThumbnailClick(e,i){e.addEventListener("click",o=>{o.preventDefault(),this.openPhoto(i,e)},{signal:this.abortController.signal})}syncCurrentGroupView(){let e=H(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=ze();this.setHash(Le(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?Te(this.state,we(e)):null}setPosByCurrentIndex(){let e=M(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=H(this.state);e&&Ie(e,O(),G(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){Se(H(this.state),O())}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.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&e.close()}commit(){this.view.render(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.view.refs.dialog.style.opacity="";let e=H(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(),ue(this.state),this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag){let o=M(this.state);this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=V(o,O(),G(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}openPhotoWithViewTransition(e){var n,c;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=(c=document.startViewTransition)==null?void 0:c.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 z;let o=(z=e==null?void 0:e.querySelector("img"))!=null?z:null;if(!o){this.state.viewer.appear=!0;return}let r=ge(o),s=o.offsetWidth,n=o.offsetHeight,c=O(),p=G(),E=p-this.state.options.headerHeight-this.state.options.footerHeight,v=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?v=p/n:v=c/s:(s>=n?i.height<E?v=i.width/s:v=E/n:i.height<E?v=i.height/n:v=E/n,s*v>c&&(v=c/s));let x=(v-1)/2*s+(c-s*v)/2,b=(v-1)/2*n+(p-n*v)/2,I=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:I||i.src||"",afterX:x,afterY:b,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=O(),i=G();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(O()===e&&G()===i||(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.view.render(this.state)))})}openPhoto(e,i){this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,this.syncedGroupId!==e.groupId&&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=G(),n=e==="top"?`translateY(-${s}px)`:`translateY(${s}px)`,c=()=>{this.finishHideEffect===c&&(this.finishHideEffect=null,o.removeEventListener("transitionend",c,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=c,r&&(r.style.transform=n),o.addEventListener("transitionend",c,!0),this.scheduleTimeout(c,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=H(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.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=M(this.state);this.state.viewer.onMove=!1,ue(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}fireEvent(e){ne(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 Oe=F;var me=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new Oe(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],me);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&me(e)}var qe=me;})();
6
+ "use strict";(()=>{var j=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};function fe(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]=fe((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var ve=fe,ne=(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)},we=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},ge=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var Xe={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,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:300};function Ee(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Ee(i)}),Object.freeze(t)}function Pe(t){return{options:Ee(ve({},Xe,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 ae(t){return t.getAttribute("data-group")||"nogroup"}function le(t){return t.group||"nogroup"}function be(t,e,i,o){let r=ae(t),s=t.getAttribute("href"),n=t.querySelector("img"),c=s;n&&(n.getAttribute(e.lazyAttribute)?c=n.getAttribute(e.lazyAttribute):n.currentSrc?c=n.currentSrc:c=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 E=t.getAttribute("data-id");return{src:s,thumb:c,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:E||i,loaded:!1,processed:!1,element:t}}function ye(t,e,i){var E,v,x,b,I;let o=le(t),r=t.src,s=(E=t.thumb)!=null?E:r,n=(v=t.caption)!=null?v:null,c=(b=(x=t.alt)!=null?x:n)!=null?b:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:c,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:(I=t.id)!=null?I:e,loaded:p,processed:!1,element:null}}function he(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 H(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function M(t){var i;let e=H(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function ue(t){let e=H(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 Se(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function Q(t,e){let i=10**e;return Math.round(t*i)/i}function V(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function xe(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,c,p,E;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(E=(o-s)/2,c=-1*E):(E=(s-o)/2,c=-1*E),{minX:Q(n,6)*e.scaleSize,minY:Q(c,6)*e.scaleSize,maxX:Q(p,6)*e.scaleSize,maxY:Q(E,6)*e.scaleSize}}function Ie(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 Le(t){let e=M(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function Te(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 de(t,e){let i=10**e;return Math.round(t*i)/i}function W(t){return{x:t.pageX,y:t.pageY}}function Ce(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}function Ye(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ae(){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}function He({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,c=null,p=null,E=null,v=!1,x=null,b=null,I=0,z=0,y=!1,Y=0,L=0,T=0;function N(){return j()}function D(a){let{width:h,height:f}=Ae();return xe(a,t.viewer,h,f)}function u(a){let{width:h,height:f}=Ae();return V(a,h,f,N())}function J(a,h){let f=M(t),m=D(f);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=m.minX:a===-1&&(t.viewer.photoPosX=m.maxX),h===1?t.viewer.photoPosY=m.minY:h===-1&&(t.viewer.photoPosY=m.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let R=setInterval(()=>{if(y||s||v||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=L,t.viewer.photoPosY+=T;let a=M(t);if(!a)return;let h=D(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,L*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,L*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,T*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,T*=-.2);let f=Ye(L,T),m=f.force-t.options.registance;Math.abs(m)<.5||(L=Math.cos(f.theta)*m,T=Math.sin(f.theta)*m,e.onPhotoDragMove())},t.options.forceInterval);function $(a,h){(a>5||a<-5)&&(L+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(T+=h*.05)}function K(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||y||s||v||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?$(a.gamma,a.beta):h===90?$(a.beta,a.gamma):h===-90?$(-a.beta,-a.gamma):h===180&&$(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",K,{signal:i});function B(){y=!0,s=!1,v=!1;let a=Array.from(o.values());Y=Ce(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function U(a){let h=W(a);s=!0,n=!0,c=h,p=h}function _(a){v=!0;let h=W(a);b=h,x=h}function Z(a){var h,f;try{(f=(h=a.currentTarget).setPointerCapture)==null||f.call(h,a.pointerId)}catch(m){}if(o.set(a.pointerId,W(a)),o.size>1){B();return}if(t.viewer.scale){_(a);return}U(a)}function ee(){let a=Array.from(o.values()),h=Ce(a[0],a[1]),f=(h-Y)/100,m=t.viewer.scaleSize,C=t.viewer.photoPosX,A=t.viewer.photoPosY;t.viewer.scaleSize+=de(f,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<m&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-m)*C,t.viewer.photoPosY=(1+t.viewer.scaleSize-m)*A);let X=M(t);if(X){let re=u(X);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>re}Y=h,e.onGestureMove()}function te(a){let h=W(a),f=h.x-p.x,m=h.y-c.y;n&&(e.onSwipeStart(),n=!1,E=Math.abs(f)>Math.abs(m)?"horizontal":"vertical"),E==="horizontal"?t.viewer.translateX+=f:t.viewer.translateY=m,p=h,e.onSwipeMove()}function ie(a){let h=W(a),f=h.x-b.x,m=h.y-b.y,C=de(t.viewer.scaleSize*f,6),A=de(t.viewer.scaleSize*m,6);t.viewer.photoPosX+=C,I=C,t.viewer.photoPosY+=A,z=A,b=h,e.onPhotoDragMove()}function oe(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,W(a)),y){ee();return}if(v){ie(a);return}te(a)}}function d(){y=!1;let a=M(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 l(){var pe;s=!1;let a=c,h=p,f=Date.now(),m=r-f,C=h.x-a.x,A=h.y-a.y,X=C===0&&A===0;if(!N()&&X){e.onTap();return}if(Math.abs(m)<=500&&X){e.onTap();return}r=f;let re=(pe=H(t))!=null?pe:[];if(E==="horizontal"){let k="stay";C>=t.options.swipeOffset&&t.viewer.currentIndex!==0?k="prev":C<=-t.options.swipeOffset&&t.viewer.currentIndex!==re.length-1&&(k="next"),e.onSwipeEnd(k)}else{let k="stay";t.options.swipeBottomToClose&&A>=t.options.swipeOffset?k="close-bottom":t.options.swipeTopToClose&&A<=-t.options.swipeOffset&&(k="close-top"),e.onSwipeEnd(k)}}function P(){v=!1;let a=b,h=x;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let f=M(t);if(!f){e.onPhotoDragEnd(null);return}let m=D(f),C=t.options.swipeOffset*t.viewer.scaleSize,A=0,X=0;if(t.viewer.photoPosX>m.maxX?A=-1:t.viewer.photoPosX<m.minX&&(A=1),t.viewer.photoPosY>m.maxY?X=-1:t.viewer.photoPosY<m.minY&&(X=1),t.viewer.photoPosX-m.maxX>C&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(m.minX-t.viewer.photoPosX>C&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}A===0&&X===0?(L=I/5,T=z/5):J(A,X),e.onPhotoDragEnd(null)}function g(a){if(o.delete(a.pointerId),y){o.size<2&&d();return}if(v){P();return}s&&l()}function w(...a){for(let h of a)h.addEventListener("pointerdown",Z,{signal:i}),h.addEventListener("pointermove",oe,{signal:i}),h.addEventListener("pointerup",g,{signal:i}),h.addEventListener("pointercancel",g,{signal:i})}function S(){clearInterval(R)}return{attach:w,detach:S}}function q(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function ce(){let t=document.createElement("button");return t.type="button",t}function Ne(t){return t.replace(/"/g,'\\"')}function Me({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let c=document.createElement("dialog");c.className=r.smartPhoto,c.setAttribute("aria-labelledby",`smartphoto-${t}-title`),c.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let E=document.createElement("div");E.className=r.smartPhotoInner;let v=document.createElement("div");v.className=r.smartPhotoHeader;let x=document.createElement("span");x.className=r.smartPhotoCount;let b=document.createElement("h1");b.id=`smartphoto-${t}-title`,b.className=r.smartPhotoCaption,b.setAttribute("tabindex","-1");let I=document.createElement("button");I.className=r.smartPhotoDismiss,I.appendChild(q(s.closeDialog)),I.addEventListener("click",()=>i.onDismiss(),{signal:o}),v.append(x,b,I);let z=document.createElement("div");z.className=r.smartPhotoContent,z.addEventListener("click",d=>{d.target===z&&i.onBackdropClick()},{signal:o});let y=document.createElement("ul");y.className=r.smartPhotoList,y.setAttribute("role","region"),y.setAttribute("aria-roledescription","carousel"),y.setAttribute("aria-label",s.carouselLabel),y.setAttribute("aria-live","polite"),y.setAttribute("aria-atomic","false"),E.append(v,z,y);let Y=null,L=null,T=null;if(e.arrows){Y=document.createElement("ul"),Y.className=r.smartPhotoArrows,L=document.createElement("li"),L.className=r.smartPhotoArrowLeft;let d=ce();d.appendChild(q(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),L.appendChild(d),T=document.createElement("li"),T.className=r.smartPhotoArrowRight;let l=ce();l.appendChild(q(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),T.appendChild(l),Y.append(L,T),E.appendChild(Y)}let N=null,D=null;e.nav&&(N=document.createElement("nav"),N.className=r.smartPhotoNav,N.setAttribute("aria-label","Choose slide to display"),D=document.createElement("ul"),N.appendChild(D),E.appendChild(N)),p.appendChild(E),c.appendChild(p),n.appendChild(c);let u={dialog:c,count:x,caption:b,dismiss:I,content:z,list:y,arrows:Y,arrowLeft:L,arrowRight:T,nav:N,navList:D,slides:new Map,imgClone:null};function J(){let d=document.createElement("div");d.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,d.appendChild(l),d}function R(d){var g,w;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let P=document.createElement("img");return P.className=r.smartPhotoImg,P.src=(g=d.src)!=null?g:"",P.alt=(w=d.alt)!=null?w:"",P.addEventListener("dragstart",S=>S.preventDefault(),{signal:o}),l.appendChild(P),{imgWrap:l,img:P}}function $(d,l){var P;u.list.replaceChildren(),(P=u.navList)==null||P.replaceChildren(),u.slides=new Map,d.forEach(g=>{var a,h;let w=document.createElement("li");w.setAttribute("role","group"),w.setAttribute("aria-roledescription","slide"),w.setAttribute("aria-label",`${g.index+1} of ${d.length}`);let S={li:w,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(g.processed){let{imgWrap:f,img:m}=R(g);w.appendChild(f),S.imgWrap=f,S.img=m}else{let f=J();w.appendChild(f),S.loaderWrap=f}if(u.list.appendChild(w),u.slides.set(g,S),u.navList){let f=document.createElement("li"),m=ce();m.style.backgroundImage=`url("${Ne((a=g.thumb)!=null?a:"")}")`;let C=g.index;m.addEventListener("click",()=>i.onNavigate(C),{signal:o}),m.appendChild(q(`go to ${(h=g.caption)!=null?h:""}`)),f.appendChild(m),u.navList.appendChild(f),S.navLink=m}}),U(l)}function K(d,l){var w;if(l.imgWrap||!d.processed)return l;let{imgWrap:P,img:g}=R(d);return(w=l.loaderWrap)==null||w.replaceWith(P),l.loaderWrap=null,l.imgWrap=P,l.img=g,l}function B(d){d&&document.activeElement&&d.contains(document.activeElement)&&u.caption.focus()}function U(d){let{viewer:l}=d;u.count.textContent=`${l.currentIndex+1}/${l.total}`,u.slides.forEach((P,g)=>{var a;let w=K(g,P),S=g.index===l.currentIndex;w.li.style.transform=`translate(${g.translateX}px,${g.translateY}px)`,w.li.classList.toggle("current",S),S?w.li.removeAttribute("aria-hidden"):w.li.setAttribute("aria-hidden","true"),S&&(u.caption.textContent=(a=g.caption)!=null?a:""),w.imgWrap&&w.img&&(w.imgWrap.style.transform=`translate(${g.x}px,${g.y}px) scale(${g.scale})`,w.img.style.width=`${g.width}px`,w.img.classList.toggle("active",l.appear),w.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),w.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),w.navLink&&(w.navLink.classList.toggle("current",S),S?w.navLink.setAttribute("aria-current","true"):w.navLink.removeAttribute("aria-current"))}),u.arrowLeft&&(l.showPrevArrow?u.arrowLeft.removeAttribute("aria-hidden"):(B(u.arrowLeft),u.arrowLeft.setAttribute("aria-hidden","true"))),u.arrowRight&&(l.showNextArrow?u.arrowRight.removeAttribute("aria-hidden"):(B(u.arrowRight),u.arrowRight.setAttribute("aria-hidden","true"))),u.arrows&&(l.hideUi&&B(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.nav&&(l.hideUi&&B(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function _(d){for(let[l,P]of u.slides)if(l.index===d.viewer.currentIndex)return P;return null}function Z(d){let{viewer:l}=d,P=_(d),g=P==null?void 0:P.img;g&&(g.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,g.classList.toggle(r.smartPhotoImgOnMove,l.scale),g.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),u.nav&&(l.hideUi&&B(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.arrows&&(l.hideUi&&B(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ee(d){let{viewer:l}=d;u.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,u.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function te(d){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=d.img,l.style.width=`${d.width}px`,l.style.height=`${d.height}px`,l.style.transform=`translate(${d.left}px,${d.top}px) scale(1)`,p.appendChild(l),u.imgClone=l}function ie(){var d;(d=u.imgClone)==null||d.remove(),u.imgClone=null}function oe(){n.remove()}return{root:n,refs:u,render:U,syncSlides:$,updatePhotoTransform:Z,updateListTransform:ee,showAppearEffect:te,removeAppearEffect:ie,destroy:oe}}function O(){return document.documentElement.clientWidth}function G(){return document.documentElement.clientHeight}function Be(t){return t.length>0&&t[0]instanceof Element}function De(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function ze(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var F=class{constructor(e,i){this.id=De();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.handleResize=()=>{H(this.state)&&(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(!H(this.state))return;this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=O(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==O()?(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25)},25)};o(0)};this.state=Pe(i!=null?i:{}),this.view=Me({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=He({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}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&(o.element?ne(o.element,"click"):this.openPhoto(o,null)),!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.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=ze();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=M(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=V(e,O(),G(),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,E,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(x=>x.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,c=(v=(E=i.trigger)!=null?E:s.element)!=null?v:n;this.openPhoto(s,c)}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 Element?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!Be(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=ae(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=be(e,this.state.options,o,O());return he(this.state,r),this.loadAllFired.delete(i),this.bindThumbnailClick(e,r),r}addSlideItem(e){var s,n;let i=le(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=ye(e,o,O());return he(this.state,r),this.loadAllFired.delete(i),r}bindThumbnailClick(e,i){e.addEventListener("click",o=>{o.preventDefault(),this.openPhoto(i,e)},{signal:this.abortController.signal})}syncCurrentGroupView(){let e=H(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=ze();this.setHash(Le(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?Te(this.state,we(e)):null}setPosByCurrentIndex(){let e=M(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=H(this.state);e&&Ie(e,O(),G(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){Se(H(this.state),O())}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.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&e.close()}commit(){this.view.render(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.view.refs.dialog.style.opacity="";let e=H(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(),ue(this.state),this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag){let o=M(this.state);this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=V(o,O(),G(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}openPhotoWithViewTransition(e){var n,c;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=(c=document.startViewTransition)==null?void 0:c.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 z;let o=(z=e==null?void 0:e.querySelector("img"))!=null?z:null;if(!o){this.state.viewer.appear=!0;return}let r=ge(o),s=o.offsetWidth,n=o.offsetHeight,c=O(),p=G(),E=p-this.state.options.headerHeight-this.state.options.footerHeight,v=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?v=p/n:v=c/s:(s>=n?i.height<E?v=i.width/s:v=E/n:i.height<E?v=i.height/n:v=E/n,s*v>c&&(v=c/s));let x=(v-1)/2*s+(c-s*v)/2,b=(v-1)/2*n+(p-n*v)/2,I=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:I||i.src||"",afterX:x,afterY:b,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=O(),i=G();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(O()===e&&G()===i||(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.view.render(this.state)))})}openPhoto(e,i){this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,this.syncedGroupId!==e.groupId&&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=G(),n=e==="top"?`translateY(-${s}px)`:`translateY(${s}px)`,c=()=>{this.finishHideEffect===c&&(this.finishHideEffect=null,o.removeEventListener("transitionend",c,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=c,r&&(r.style.transform=n),o.addEventListener("transitionend",c,!0),this.scheduleTimeout(c,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=H(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.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=M(this.state);this.state.viewer.onMove=!1,ue(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}fireEvent(e){ne(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 Oe=F;var me=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new Oe(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],me);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&me(e)}var Je=me;})();
package/js/smartphoto.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * SmartPhoto v2.1.0
2
+ * SmartPhoto v2.1.2
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
@@ -1101,6 +1101,9 @@ var SmartPhoto = (() => {
1101
1101
  function getWindowHeight() {
1102
1102
  return document.documentElement.clientHeight;
1103
1103
  }
1104
+ function isElementArray(source) {
1105
+ return source.length > 0 && source[0] instanceof Element;
1106
+ }
1104
1107
  function getUniqId() {
1105
1108
  return (Date.now().toString(36) + Math.random().toString(36).substring(2, 7)).toUpperCase();
1106
1109
  }
@@ -1361,7 +1364,7 @@ var SmartPhoto = (() => {
1361
1364
  }
1362
1365
  // ---- 内部: ソース取り込み ----
1363
1366
  ingestSource(source) {
1364
- if (Array.isArray(source)) {
1367
+ if (Array.isArray(source) && !isElementArray(source)) {
1365
1368
  source.forEach((slide) => {
1366
1369
  this.addSlideItem(slide);
1367
1370
  });
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * SmartPhoto v2.1.0
2
+ * SmartPhoto v2.1.2
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
6
- "use strict";var SmartPhoto=(()=>{var ne=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Ne=(t,e)=>{for(var i in e)ne(t,i,{get:e[i],enumerable:!0})},Be=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Xe(e))!Ye.call(t,r)&&r!==i&&ne(t,r,{get:()=>e[r],enumerable:!(o=Oe(e,r))||o.enumerable});return t};var De=t=>Be(ne({},"__esModule",{value:!0}),t);var Fe={};Ne(Fe,{default:()=>$e});var q=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};function fe(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]=fe((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var ve=fe,se=(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)},we=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},ge=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var Ge={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,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:300};function Ee(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Ee(i)}),Object.freeze(t)}function Pe(t){return{options:Ee(ve({},Ge,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 le(t){return t.getAttribute("data-group")||"nogroup"}function he(t){return t.group||"nogroup"}function be(t,e,i,o){let r=le(t),s=t.getAttribute("href"),n=t.querySelector("img"),c=s;n&&(n.getAttribute(e.lazyAttribute)?c=n.getAttribute(e.lazyAttribute):n.currentSrc?c=n.currentSrc:c=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 E=t.getAttribute("data-id");return{src:s,thumb:c,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:E||i,loaded:!1,processed:!1,element:t}}function ye(t,e,i){var E,v,x,b,I;let o=he(t),r=t.src,s=(E=t.thumb)!=null?E:r,n=(v=t.caption)!=null?v:null,c=(b=(x=t.alt)!=null?x:n)!=null?b:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:c,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:(I=t.id)!=null?I:e,loaded:p,processed:!1,element:null}}function ue(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 H(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function M(t){var i;let e=H(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function de(t){let e=H(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 Se(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function j(t,e){let i=10**e;return Math.round(t*i)/i}function $(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function xe(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,c,p,E;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(E=(o-s)/2,c=-1*E):(E=(s-o)/2,c=-1*E),{minX:j(n,6)*e.scaleSize,minY:j(c,6)*e.scaleSize,maxX:j(p,6)*e.scaleSize,maxY:j(E,6)*e.scaleSize}}function Ie(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 Le(t){let e=M(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function Te(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 ce(t,e){let i=10**e;return Math.round(t*i)/i}function V(t){return{x:t.pageX,y:t.pageY}}function Ce(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}function We(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ae(){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}function He({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,c=null,p=null,E=null,v=!1,x=null,b=null,I=0,z=0,y=!1,Y=0,L=0,T=0;function N(){return q()}function D(a){let{width:h,height:f}=Ae();return xe(a,t.viewer,h,f)}function u(a){let{width:h,height:f}=Ae();return $(a,h,f,N())}function Q(a,h){let f=M(t),m=D(f);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=m.minX:a===-1&&(t.viewer.photoPosX=m.maxX),h===1?t.viewer.photoPosY=m.minY:h===-1&&(t.viewer.photoPosY=m.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let R=setInterval(()=>{if(y||s||v||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=L,t.viewer.photoPosY+=T;let a=M(t);if(!a)return;let h=D(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,L*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,L*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,T*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,T*=-.2);let f=We(L,T),m=f.force-t.options.registance;Math.abs(m)<.5||(L=Math.cos(f.theta)*m,T=Math.sin(f.theta)*m,e.onPhotoDragMove())},t.options.forceInterval);function k(a,h){(a>5||a<-5)&&(L+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(T+=h*.05)}function _(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||y||s||v||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?k(a.gamma,a.beta):h===90?k(a.beta,a.gamma):h===-90?k(-a.beta,-a.gamma):h===180&&k(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",_,{signal:i});function B(){y=!0,s=!1,v=!1;let a=Array.from(o.values());Y=Ce(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function U(a){let h=V(a);s=!0,n=!0,c=h,p=h}function J(a){v=!0;let h=V(a);b=h,x=h}function Z(a){var h,f;try{(f=(h=a.currentTarget).setPointerCapture)==null||f.call(h,a.pointerId)}catch(m){}if(o.set(a.pointerId,V(a)),o.size>1){B();return}if(t.viewer.scale){J(a);return}U(a)}function ee(){let a=Array.from(o.values()),h=Ce(a[0],a[1]),f=(h-Y)/100,m=t.viewer.scaleSize,C=t.viewer.photoPosX,A=t.viewer.photoPosY;t.viewer.scaleSize+=ce(f,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<m&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-m)*C,t.viewer.photoPosY=(1+t.viewer.scaleSize-m)*A);let X=M(t);if(X){let re=u(X);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>re}Y=h,e.onGestureMove()}function te(a){let h=V(a),f=h.x-p.x,m=h.y-c.y;n&&(e.onSwipeStart(),n=!1,E=Math.abs(f)>Math.abs(m)?"horizontal":"vertical"),E==="horizontal"?t.viewer.translateX+=f:t.viewer.translateY=m,p=h,e.onSwipeMove()}function ie(a){let h=V(a),f=h.x-b.x,m=h.y-b.y,C=ce(t.viewer.scaleSize*f,6),A=ce(t.viewer.scaleSize*m,6);t.viewer.photoPosX+=C,I=C,t.viewer.photoPosY+=A,z=A,b=h,e.onPhotoDragMove()}function oe(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,V(a)),y){ee();return}if(v){ie(a);return}te(a)}}function d(){y=!1;let a=M(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 l(){var pe;s=!1;let a=c,h=p,f=Date.now(),m=r-f,C=h.x-a.x,A=h.y-a.y,X=C===0&&A===0;if(!N()&&X){e.onTap();return}if(Math.abs(m)<=500&&X){e.onTap();return}r=f;let re=(pe=H(t))!=null?pe:[];if(E==="horizontal"){let G="stay";C>=t.options.swipeOffset&&t.viewer.currentIndex!==0?G="prev":C<=-t.options.swipeOffset&&t.viewer.currentIndex!==re.length-1&&(G="next"),e.onSwipeEnd(G)}else{let G="stay";t.options.swipeBottomToClose&&A>=t.options.swipeOffset?G="close-bottom":t.options.swipeTopToClose&&A<=-t.options.swipeOffset&&(G="close-top"),e.onSwipeEnd(G)}}function P(){v=!1;let a=b,h=x;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let f=M(t);if(!f){e.onPhotoDragEnd(null);return}let m=D(f),C=t.options.swipeOffset*t.viewer.scaleSize,A=0,X=0;if(t.viewer.photoPosX>m.maxX?A=-1:t.viewer.photoPosX<m.minX&&(A=1),t.viewer.photoPosY>m.maxY?X=-1:t.viewer.photoPosY<m.minY&&(X=1),t.viewer.photoPosX-m.maxX>C&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(m.minX-t.viewer.photoPosX>C&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}A===0&&X===0?(L=I/5,T=z/5):Q(A,X),e.onPhotoDragEnd(null)}function g(a){if(o.delete(a.pointerId),y){o.size<2&&d();return}if(v){P();return}s&&l()}function w(...a){for(let h of a)h.addEventListener("pointerdown",Z,{signal:i}),h.addEventListener("pointermove",oe,{signal:i}),h.addEventListener("pointerup",g,{signal:i}),h.addEventListener("pointercancel",g,{signal:i})}function S(){clearInterval(R)}return{attach:w,detach:S}}function K(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function me(){let t=document.createElement("button");return t.type="button",t}function ke(t){return t.replace(/"/g,'\\"')}function Me({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let c=document.createElement("dialog");c.className=r.smartPhoto,c.setAttribute("aria-labelledby",`smartphoto-${t}-title`),c.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let E=document.createElement("div");E.className=r.smartPhotoInner;let v=document.createElement("div");v.className=r.smartPhotoHeader;let x=document.createElement("span");x.className=r.smartPhotoCount;let b=document.createElement("h1");b.id=`smartphoto-${t}-title`,b.className=r.smartPhotoCaption,b.setAttribute("tabindex","-1");let I=document.createElement("button");I.className=r.smartPhotoDismiss,I.appendChild(K(s.closeDialog)),I.addEventListener("click",()=>i.onDismiss(),{signal:o}),v.append(x,b,I);let z=document.createElement("div");z.className=r.smartPhotoContent,z.addEventListener("click",d=>{d.target===z&&i.onBackdropClick()},{signal:o});let y=document.createElement("ul");y.className=r.smartPhotoList,y.setAttribute("role","region"),y.setAttribute("aria-roledescription","carousel"),y.setAttribute("aria-label",s.carouselLabel),y.setAttribute("aria-live","polite"),y.setAttribute("aria-atomic","false"),E.append(v,z,y);let Y=null,L=null,T=null;if(e.arrows){Y=document.createElement("ul"),Y.className=r.smartPhotoArrows,L=document.createElement("li"),L.className=r.smartPhotoArrowLeft;let d=me();d.appendChild(K(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),L.appendChild(d),T=document.createElement("li"),T.className=r.smartPhotoArrowRight;let l=me();l.appendChild(K(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),T.appendChild(l),Y.append(L,T),E.appendChild(Y)}let N=null,D=null;e.nav&&(N=document.createElement("nav"),N.className=r.smartPhotoNav,N.setAttribute("aria-label","Choose slide to display"),D=document.createElement("ul"),N.appendChild(D),E.appendChild(N)),p.appendChild(E),c.appendChild(p),n.appendChild(c);let u={dialog:c,count:x,caption:b,dismiss:I,content:z,list:y,arrows:Y,arrowLeft:L,arrowRight:T,nav:N,navList:D,slides:new Map,imgClone:null};function Q(){let d=document.createElement("div");d.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,d.appendChild(l),d}function R(d){var g,w;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let P=document.createElement("img");return P.className=r.smartPhotoImg,P.src=(g=d.src)!=null?g:"",P.alt=(w=d.alt)!=null?w:"",P.addEventListener("dragstart",S=>S.preventDefault(),{signal:o}),l.appendChild(P),{imgWrap:l,img:P}}function k(d,l){var P;u.list.replaceChildren(),(P=u.navList)==null||P.replaceChildren(),u.slides=new Map,d.forEach(g=>{var a,h;let w=document.createElement("li");w.setAttribute("role","group"),w.setAttribute("aria-roledescription","slide"),w.setAttribute("aria-label",`${g.index+1} of ${d.length}`);let S={li:w,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(g.processed){let{imgWrap:f,img:m}=R(g);w.appendChild(f),S.imgWrap=f,S.img=m}else{let f=Q();w.appendChild(f),S.loaderWrap=f}if(u.list.appendChild(w),u.slides.set(g,S),u.navList){let f=document.createElement("li"),m=me();m.style.backgroundImage=`url("${ke((a=g.thumb)!=null?a:"")}")`;let C=g.index;m.addEventListener("click",()=>i.onNavigate(C),{signal:o}),m.appendChild(K(`go to ${(h=g.caption)!=null?h:""}`)),f.appendChild(m),u.navList.appendChild(f),S.navLink=m}}),U(l)}function _(d,l){var w;if(l.imgWrap||!d.processed)return l;let{imgWrap:P,img:g}=R(d);return(w=l.loaderWrap)==null||w.replaceWith(P),l.loaderWrap=null,l.imgWrap=P,l.img=g,l}function B(d){d&&document.activeElement&&d.contains(document.activeElement)&&u.caption.focus()}function U(d){let{viewer:l}=d;u.count.textContent=`${l.currentIndex+1}/${l.total}`,u.slides.forEach((P,g)=>{var a;let w=_(g,P),S=g.index===l.currentIndex;w.li.style.transform=`translate(${g.translateX}px,${g.translateY}px)`,w.li.classList.toggle("current",S),S?w.li.removeAttribute("aria-hidden"):w.li.setAttribute("aria-hidden","true"),S&&(u.caption.textContent=(a=g.caption)!=null?a:""),w.imgWrap&&w.img&&(w.imgWrap.style.transform=`translate(${g.x}px,${g.y}px) scale(${g.scale})`,w.img.style.width=`${g.width}px`,w.img.classList.toggle("active",l.appear),w.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),w.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),w.navLink&&(w.navLink.classList.toggle("current",S),S?w.navLink.setAttribute("aria-current","true"):w.navLink.removeAttribute("aria-current"))}),u.arrowLeft&&(l.showPrevArrow?u.arrowLeft.removeAttribute("aria-hidden"):(B(u.arrowLeft),u.arrowLeft.setAttribute("aria-hidden","true"))),u.arrowRight&&(l.showNextArrow?u.arrowRight.removeAttribute("aria-hidden"):(B(u.arrowRight),u.arrowRight.setAttribute("aria-hidden","true"))),u.arrows&&(l.hideUi&&B(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.nav&&(l.hideUi&&B(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function J(d){for(let[l,P]of u.slides)if(l.index===d.viewer.currentIndex)return P;return null}function Z(d){let{viewer:l}=d,P=J(d),g=P==null?void 0:P.img;g&&(g.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,g.classList.toggle(r.smartPhotoImgOnMove,l.scale),g.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),u.nav&&(l.hideUi&&B(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.arrows&&(l.hideUi&&B(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ee(d){let{viewer:l}=d;u.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,u.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function te(d){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=d.img,l.style.width=`${d.width}px`,l.style.height=`${d.height}px`,l.style.transform=`translate(${d.left}px,${d.top}px) scale(1)`,p.appendChild(l),u.imgClone=l}function ie(){var d;(d=u.imgClone)==null||d.remove(),u.imgClone=null}function oe(){n.remove()}return{root:n,refs:u,render:U,syncSlides:k,updatePhotoTransform:Z,updateListTransform:ee,showAppearEffect:te,removeAppearEffect:ie,destroy:oe}}function O(){return document.documentElement.clientWidth}function W(){return document.documentElement.clientHeight}function Ve(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function ze(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var F=class{constructor(e,i){this.id=Ve();this.abortController=new AbortController;this.isSmartPhoneFlag=q();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.handleResize=()=>{H(this.state)&&(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(!H(this.state))return;this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=O(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==O()?(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25)},25)};o(0)};this.state=Pe(i!=null?i:{}),this.view=Me({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=He({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}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&(o.element?se(o.element,"click"):this.openPhoto(o,null)),!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.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=ze();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=M(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=$(e,O(),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,E,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(x=>x.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,c=(v=(E=i.trigger)!=null?E:s.element)!=null?v:n;this.openPhoto(s,c)}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 Element?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(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=le(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=be(e,this.state.options,o,O());return ue(this.state,r),this.loadAllFired.delete(i),this.bindThumbnailClick(e,r),r}addSlideItem(e){var s,n;let i=he(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=ye(e,o,O());return ue(this.state,r),this.loadAllFired.delete(i),r}bindThumbnailClick(e,i){e.addEventListener("click",o=>{o.preventDefault(),this.openPhoto(i,e)},{signal:this.abortController.signal})}syncCurrentGroupView(){let e=H(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=ze();this.setHash(Le(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?Te(this.state,we(e)):null}setPosByCurrentIndex(){let e=M(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=H(this.state);e&&Ie(e,O(),W(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){Se(H(this.state),O())}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.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&e.close()}commit(){this.view.render(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.view.refs.dialog.style.opacity="";let e=H(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(),de(this.state),this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag){let o=M(this.state);this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=$(o,O(),W(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}openPhotoWithViewTransition(e){var n,c;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=(c=document.startViewTransition)==null?void 0:c.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 z;let o=(z=e==null?void 0:e.querySelector("img"))!=null?z:null;if(!o){this.state.viewer.appear=!0;return}let r=ge(o),s=o.offsetWidth,n=o.offsetHeight,c=O(),p=W(),E=p-this.state.options.headerHeight-this.state.options.footerHeight,v=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?v=p/n:v=c/s:(s>=n?i.height<E?v=i.width/s:v=E/n:i.height<E?v=i.height/n:v=E/n,s*v>c&&(v=c/s));let x=(v-1)/2*s+(c-s*v)/2,b=(v-1)/2*n+(p-n*v)/2,I=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:I||i.src||"",afterX:x,afterY:b,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=O(),i=W();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(O()===e&&W()===i||(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.view.render(this.state)))})}openPhoto(e,i){this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,this.syncedGroupId!==e.groupId&&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)`,c=()=>{this.finishHideEffect===c&&(this.finishHideEffect=null,o.removeEventListener("transitionend",c,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=c,r&&(r.style.transform=n),o.addEventListener("transitionend",c,!0),this.scheduleTimeout(c,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=H(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.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=M(this.state);this.state.viewer.onMove=!1,de(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}fireEvent(e){se(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 $e=F;return De(Fe);})();
6
+ "use strict";var SmartPhoto=(()=>{var ne=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Ne=(t,e)=>{for(var i in e)ne(t,i,{get:e[i],enumerable:!0})},Be=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Xe(e))!Ye.call(t,r)&&r!==i&&ne(t,r,{get:()=>e[r],enumerable:!(o=Oe(e,r))||o.enumerable});return t};var De=t=>Be(ne({},"__esModule",{value:!0}),t);var Re={};Ne(Re,{default:()=>Fe});var q=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};function fe(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]=fe((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var ve=fe,se=(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)},we=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},ge=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var Ge={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,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:300};function Ee(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Ee(i)}),Object.freeze(t)}function Pe(t){return{options:Ee(ve({},Ge,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 le(t){return t.getAttribute("data-group")||"nogroup"}function he(t){return t.group||"nogroup"}function be(t,e,i,o){let r=le(t),s=t.getAttribute("href"),n=t.querySelector("img"),c=s;n&&(n.getAttribute(e.lazyAttribute)?c=n.getAttribute(e.lazyAttribute):n.currentSrc?c=n.currentSrc:c=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 E=t.getAttribute("data-id");return{src:s,thumb:c,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:E||i,loaded:!1,processed:!1,element:t}}function ye(t,e,i){var E,v,x,b,I;let o=he(t),r=t.src,s=(E=t.thumb)!=null?E:r,n=(v=t.caption)!=null?v:null,c=(b=(x=t.alt)!=null?x:n)!=null?b:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:c,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:(I=t.id)!=null?I:e,loaded:p,processed:!1,element:null}}function ue(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 H(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function M(t){var i;let e=H(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function de(t){let e=H(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 Se(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function j(t,e){let i=10**e;return Math.round(t*i)/i}function $(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function xe(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,c,p,E;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(E=(o-s)/2,c=-1*E):(E=(s-o)/2,c=-1*E),{minX:j(n,6)*e.scaleSize,minY:j(c,6)*e.scaleSize,maxX:j(p,6)*e.scaleSize,maxY:j(E,6)*e.scaleSize}}function Ie(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 Le(t){let e=M(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function Te(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 ce(t,e){let i=10**e;return Math.round(t*i)/i}function V(t){return{x:t.pageX,y:t.pageY}}function Ce(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}function ke(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ae(){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}function He({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,c=null,p=null,E=null,v=!1,x=null,b=null,I=0,z=0,y=!1,Y=0,L=0,T=0;function N(){return q()}function D(a){let{width:h,height:f}=Ae();return xe(a,t.viewer,h,f)}function u(a){let{width:h,height:f}=Ae();return $(a,h,f,N())}function Q(a,h){let f=M(t),m=D(f);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=m.minX:a===-1&&(t.viewer.photoPosX=m.maxX),h===1?t.viewer.photoPosY=m.minY:h===-1&&(t.viewer.photoPosY=m.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let R=setInterval(()=>{if(y||s||v||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=L,t.viewer.photoPosY+=T;let a=M(t);if(!a)return;let h=D(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,L*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,L*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,T*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,T*=-.2);let f=ke(L,T),m=f.force-t.options.registance;Math.abs(m)<.5||(L=Math.cos(f.theta)*m,T=Math.sin(f.theta)*m,e.onPhotoDragMove())},t.options.forceInterval);function W(a,h){(a>5||a<-5)&&(L+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(T+=h*.05)}function _(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||y||s||v||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?W(a.gamma,a.beta):h===90?W(a.beta,a.gamma):h===-90?W(-a.beta,-a.gamma):h===180&&W(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",_,{signal:i});function B(){y=!0,s=!1,v=!1;let a=Array.from(o.values());Y=Ce(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function U(a){let h=V(a);s=!0,n=!0,c=h,p=h}function J(a){v=!0;let h=V(a);b=h,x=h}function Z(a){var h,f;try{(f=(h=a.currentTarget).setPointerCapture)==null||f.call(h,a.pointerId)}catch(m){}if(o.set(a.pointerId,V(a)),o.size>1){B();return}if(t.viewer.scale){J(a);return}U(a)}function ee(){let a=Array.from(o.values()),h=Ce(a[0],a[1]),f=(h-Y)/100,m=t.viewer.scaleSize,C=t.viewer.photoPosX,A=t.viewer.photoPosY;t.viewer.scaleSize+=ce(f,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<m&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-m)*C,t.viewer.photoPosY=(1+t.viewer.scaleSize-m)*A);let X=M(t);if(X){let re=u(X);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>re}Y=h,e.onGestureMove()}function te(a){let h=V(a),f=h.x-p.x,m=h.y-c.y;n&&(e.onSwipeStart(),n=!1,E=Math.abs(f)>Math.abs(m)?"horizontal":"vertical"),E==="horizontal"?t.viewer.translateX+=f:t.viewer.translateY=m,p=h,e.onSwipeMove()}function ie(a){let h=V(a),f=h.x-b.x,m=h.y-b.y,C=ce(t.viewer.scaleSize*f,6),A=ce(t.viewer.scaleSize*m,6);t.viewer.photoPosX+=C,I=C,t.viewer.photoPosY+=A,z=A,b=h,e.onPhotoDragMove()}function oe(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,V(a)),y){ee();return}if(v){ie(a);return}te(a)}}function d(){y=!1;let a=M(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 l(){var pe;s=!1;let a=c,h=p,f=Date.now(),m=r-f,C=h.x-a.x,A=h.y-a.y,X=C===0&&A===0;if(!N()&&X){e.onTap();return}if(Math.abs(m)<=500&&X){e.onTap();return}r=f;let re=(pe=H(t))!=null?pe:[];if(E==="horizontal"){let G="stay";C>=t.options.swipeOffset&&t.viewer.currentIndex!==0?G="prev":C<=-t.options.swipeOffset&&t.viewer.currentIndex!==re.length-1&&(G="next"),e.onSwipeEnd(G)}else{let G="stay";t.options.swipeBottomToClose&&A>=t.options.swipeOffset?G="close-bottom":t.options.swipeTopToClose&&A<=-t.options.swipeOffset&&(G="close-top"),e.onSwipeEnd(G)}}function P(){v=!1;let a=b,h=x;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let f=M(t);if(!f){e.onPhotoDragEnd(null);return}let m=D(f),C=t.options.swipeOffset*t.viewer.scaleSize,A=0,X=0;if(t.viewer.photoPosX>m.maxX?A=-1:t.viewer.photoPosX<m.minX&&(A=1),t.viewer.photoPosY>m.maxY?X=-1:t.viewer.photoPosY<m.minY&&(X=1),t.viewer.photoPosX-m.maxX>C&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(m.minX-t.viewer.photoPosX>C&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}A===0&&X===0?(L=I/5,T=z/5):Q(A,X),e.onPhotoDragEnd(null)}function g(a){if(o.delete(a.pointerId),y){o.size<2&&d();return}if(v){P();return}s&&l()}function w(...a){for(let h of a)h.addEventListener("pointerdown",Z,{signal:i}),h.addEventListener("pointermove",oe,{signal:i}),h.addEventListener("pointerup",g,{signal:i}),h.addEventListener("pointercancel",g,{signal:i})}function S(){clearInterval(R)}return{attach:w,detach:S}}function K(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function me(){let t=document.createElement("button");return t.type="button",t}function We(t){return t.replace(/"/g,'\\"')}function Me({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let c=document.createElement("dialog");c.className=r.smartPhoto,c.setAttribute("aria-labelledby",`smartphoto-${t}-title`),c.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let E=document.createElement("div");E.className=r.smartPhotoInner;let v=document.createElement("div");v.className=r.smartPhotoHeader;let x=document.createElement("span");x.className=r.smartPhotoCount;let b=document.createElement("h1");b.id=`smartphoto-${t}-title`,b.className=r.smartPhotoCaption,b.setAttribute("tabindex","-1");let I=document.createElement("button");I.className=r.smartPhotoDismiss,I.appendChild(K(s.closeDialog)),I.addEventListener("click",()=>i.onDismiss(),{signal:o}),v.append(x,b,I);let z=document.createElement("div");z.className=r.smartPhotoContent,z.addEventListener("click",d=>{d.target===z&&i.onBackdropClick()},{signal:o});let y=document.createElement("ul");y.className=r.smartPhotoList,y.setAttribute("role","region"),y.setAttribute("aria-roledescription","carousel"),y.setAttribute("aria-label",s.carouselLabel),y.setAttribute("aria-live","polite"),y.setAttribute("aria-atomic","false"),E.append(v,z,y);let Y=null,L=null,T=null;if(e.arrows){Y=document.createElement("ul"),Y.className=r.smartPhotoArrows,L=document.createElement("li"),L.className=r.smartPhotoArrowLeft;let d=me();d.appendChild(K(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),L.appendChild(d),T=document.createElement("li"),T.className=r.smartPhotoArrowRight;let l=me();l.appendChild(K(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),T.appendChild(l),Y.append(L,T),E.appendChild(Y)}let N=null,D=null;e.nav&&(N=document.createElement("nav"),N.className=r.smartPhotoNav,N.setAttribute("aria-label","Choose slide to display"),D=document.createElement("ul"),N.appendChild(D),E.appendChild(N)),p.appendChild(E),c.appendChild(p),n.appendChild(c);let u={dialog:c,count:x,caption:b,dismiss:I,content:z,list:y,arrows:Y,arrowLeft:L,arrowRight:T,nav:N,navList:D,slides:new Map,imgClone:null};function Q(){let d=document.createElement("div");d.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,d.appendChild(l),d}function R(d){var g,w;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let P=document.createElement("img");return P.className=r.smartPhotoImg,P.src=(g=d.src)!=null?g:"",P.alt=(w=d.alt)!=null?w:"",P.addEventListener("dragstart",S=>S.preventDefault(),{signal:o}),l.appendChild(P),{imgWrap:l,img:P}}function W(d,l){var P;u.list.replaceChildren(),(P=u.navList)==null||P.replaceChildren(),u.slides=new Map,d.forEach(g=>{var a,h;let w=document.createElement("li");w.setAttribute("role","group"),w.setAttribute("aria-roledescription","slide"),w.setAttribute("aria-label",`${g.index+1} of ${d.length}`);let S={li:w,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(g.processed){let{imgWrap:f,img:m}=R(g);w.appendChild(f),S.imgWrap=f,S.img=m}else{let f=Q();w.appendChild(f),S.loaderWrap=f}if(u.list.appendChild(w),u.slides.set(g,S),u.navList){let f=document.createElement("li"),m=me();m.style.backgroundImage=`url("${We((a=g.thumb)!=null?a:"")}")`;let C=g.index;m.addEventListener("click",()=>i.onNavigate(C),{signal:o}),m.appendChild(K(`go to ${(h=g.caption)!=null?h:""}`)),f.appendChild(m),u.navList.appendChild(f),S.navLink=m}}),U(l)}function _(d,l){var w;if(l.imgWrap||!d.processed)return l;let{imgWrap:P,img:g}=R(d);return(w=l.loaderWrap)==null||w.replaceWith(P),l.loaderWrap=null,l.imgWrap=P,l.img=g,l}function B(d){d&&document.activeElement&&d.contains(document.activeElement)&&u.caption.focus()}function U(d){let{viewer:l}=d;u.count.textContent=`${l.currentIndex+1}/${l.total}`,u.slides.forEach((P,g)=>{var a;let w=_(g,P),S=g.index===l.currentIndex;w.li.style.transform=`translate(${g.translateX}px,${g.translateY}px)`,w.li.classList.toggle("current",S),S?w.li.removeAttribute("aria-hidden"):w.li.setAttribute("aria-hidden","true"),S&&(u.caption.textContent=(a=g.caption)!=null?a:""),w.imgWrap&&w.img&&(w.imgWrap.style.transform=`translate(${g.x}px,${g.y}px) scale(${g.scale})`,w.img.style.width=`${g.width}px`,w.img.classList.toggle("active",l.appear),w.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),w.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),w.navLink&&(w.navLink.classList.toggle("current",S),S?w.navLink.setAttribute("aria-current","true"):w.navLink.removeAttribute("aria-current"))}),u.arrowLeft&&(l.showPrevArrow?u.arrowLeft.removeAttribute("aria-hidden"):(B(u.arrowLeft),u.arrowLeft.setAttribute("aria-hidden","true"))),u.arrowRight&&(l.showNextArrow?u.arrowRight.removeAttribute("aria-hidden"):(B(u.arrowRight),u.arrowRight.setAttribute("aria-hidden","true"))),u.arrows&&(l.hideUi&&B(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.nav&&(l.hideUi&&B(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function J(d){for(let[l,P]of u.slides)if(l.index===d.viewer.currentIndex)return P;return null}function Z(d){let{viewer:l}=d,P=J(d),g=P==null?void 0:P.img;g&&(g.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,g.classList.toggle(r.smartPhotoImgOnMove,l.scale),g.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),u.nav&&(l.hideUi&&B(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.arrows&&(l.hideUi&&B(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ee(d){let{viewer:l}=d;u.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,u.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function te(d){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=d.img,l.style.width=`${d.width}px`,l.style.height=`${d.height}px`,l.style.transform=`translate(${d.left}px,${d.top}px) scale(1)`,p.appendChild(l),u.imgClone=l}function ie(){var d;(d=u.imgClone)==null||d.remove(),u.imgClone=null}function oe(){n.remove()}return{root:n,refs:u,render:U,syncSlides:W,updatePhotoTransform:Z,updateListTransform:ee,showAppearEffect:te,removeAppearEffect:ie,destroy:oe}}function O(){return document.documentElement.clientWidth}function k(){return document.documentElement.clientHeight}function Ve(t){return t.length>0&&t[0]instanceof Element}function $e(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function ze(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var F=class{constructor(e,i){this.id=$e();this.abortController=new AbortController;this.isSmartPhoneFlag=q();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.handleResize=()=>{H(this.state)&&(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(!H(this.state))return;this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=O(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==O()?(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25)},25)};o(0)};this.state=Pe(i!=null?i:{}),this.view=Me({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=He({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}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&(o.element?se(o.element,"click"):this.openPhoto(o,null)),!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.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=ze();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=M(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=$(e,O(),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,E,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(x=>x.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,c=(v=(E=i.trigger)!=null?E:s.element)!=null?v:n;this.openPhoto(s,c)}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 Element?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!Ve(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=le(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=be(e,this.state.options,o,O());return ue(this.state,r),this.loadAllFired.delete(i),this.bindThumbnailClick(e,r),r}addSlideItem(e){var s,n;let i=he(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=ye(e,o,O());return ue(this.state,r),this.loadAllFired.delete(i),r}bindThumbnailClick(e,i){e.addEventListener("click",o=>{o.preventDefault(),this.openPhoto(i,e)},{signal:this.abortController.signal})}syncCurrentGroupView(){let e=H(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=ze();this.setHash(Le(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?Te(this.state,we(e)):null}setPosByCurrentIndex(){let e=M(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=H(this.state);e&&Ie(e,O(),k(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){Se(H(this.state),O())}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.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&e.close()}commit(){this.view.render(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.view.refs.dialog.style.opacity="";let e=H(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(),de(this.state),this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag){let o=M(this.state);this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=$(o,O(),k(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}openPhotoWithViewTransition(e){var n,c;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=(c=document.startViewTransition)==null?void 0:c.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 z;let o=(z=e==null?void 0:e.querySelector("img"))!=null?z:null;if(!o){this.state.viewer.appear=!0;return}let r=ge(o),s=o.offsetWidth,n=o.offsetHeight,c=O(),p=k(),E=p-this.state.options.headerHeight-this.state.options.footerHeight,v=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?v=p/n:v=c/s:(s>=n?i.height<E?v=i.width/s:v=E/n:i.height<E?v=i.height/n:v=E/n,s*v>c&&(v=c/s));let x=(v-1)/2*s+(c-s*v)/2,b=(v-1)/2*n+(p-n*v)/2,I=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:I||i.src||"",afterX:x,afterY:b,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=O(),i=k();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(O()===e&&k()===i||(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.view.render(this.state)))})}openPhoto(e,i){this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,this.syncedGroupId!==e.groupId&&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)`,c=()=>{this.finishHideEffect===c&&(this.finishHideEffect=null,o.removeEventListener("transitionend",c,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=c,r&&(r.style.transform=n),o.addEventListener("transitionend",c,!0),this.scheduleTimeout(c,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=H(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.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=M(this.state);this.state.viewer.onMove=!1,de(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}fireEvent(e){se(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 Fe=F;return De(Re);})();
7
7
  SmartPhoto = SmartPhoto.default;
package/lib/smartphoto.js CHANGED
@@ -1084,6 +1084,9 @@ function getWindowWidth() {
1084
1084
  function getWindowHeight() {
1085
1085
  return document.documentElement.clientHeight;
1086
1086
  }
1087
+ function isElementArray(source) {
1088
+ return source.length > 0 && source[0] instanceof Element;
1089
+ }
1087
1090
  function getUniqId() {
1088
1091
  return (Date.now().toString(36) + Math.random().toString(36).substring(2, 7)).toUpperCase();
1089
1092
  }
@@ -1342,7 +1345,7 @@ var SmartPhoto = class {
1342
1345
  }
1343
1346
  // ---- 内部: ソース取り込み ----
1344
1347
  ingestSource(source) {
1345
- if (Array.isArray(source)) {
1348
+ if (Array.isArray(source) && !isElementArray(source)) {
1346
1349
  source.forEach((slide) => {
1347
1350
  this.addSlideItem(slide);
1348
1351
  });
@@ -1058,6 +1058,9 @@ function getWindowWidth() {
1058
1058
  function getWindowHeight() {
1059
1059
  return document.documentElement.clientHeight;
1060
1060
  }
1061
+ function isElementArray(source) {
1062
+ return source.length > 0 && source[0] instanceof Element;
1063
+ }
1061
1064
  function getUniqId() {
1062
1065
  return (Date.now().toString(36) + Math.random().toString(36).substring(2, 7)).toUpperCase();
1063
1066
  }
@@ -1316,7 +1319,7 @@ var SmartPhoto = class {
1316
1319
  }
1317
1320
  // ---- 内部: ソース取り込み ----
1318
1321
  ingestSource(source) {
1319
- if (Array.isArray(source)) {
1322
+ if (Array.isArray(source) && !isElementArray(source)) {
1320
1323
  source.forEach((slide) => {
1321
1324
  this.addSlideItem(slide);
1322
1325
  });
@@ -130,7 +130,7 @@ export interface Slide {
130
130
  width?: number;
131
131
  height?: number;
132
132
  }
133
- export type SmartPhotoSource = string | NodeListOf<Element> | Slide[];
133
+ export type SmartPhotoSource = string | NodeListOf<Element> | Element[] | Slide[];
134
134
  export type SmartPhotoEvent = "open" | "close" | "change" | "swipestart" | "swipeend" | "zoomin" | "zoomout" | "gesturestart" | "gestureend" | "loadall";
135
135
  export type SwipeEndResult = "prev" | "next" | "close-top" | "close-bottom" | "stay";
136
136
  export type PhotoDragEndResult = "prev" | "next" | "zoom-out" | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smartphoto",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "smartphoto",
5
5
  "homepage": "https://developer.a-blogcms.jp",
6
6
  "main": "./lib/smartphoto.js",
@@ -16,7 +16,9 @@
16
16
  "types": "./lib/types/index.d.ts",
17
17
  "import": "./lib/smartphoto.mjs",
18
18
  "require": "./lib/smartphoto.js"
19
- }
19
+ },
20
+ "./css/*": "./css/*",
21
+ "./package.json": "./package.json"
20
22
  },
21
23
  "publishConfig": {
22
24
  "access": "public"