smartphoto 2.1.14 → 2.1.15
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 +2 -2
- package/js/jquery-smartphoto.js +7 -7
- package/js/jquery-smartphoto.min.js +2 -2
- package/js/smartphoto.js +7 -7
- package/js/smartphoto.min.js +2 -2
- package/lib/smartphoto.js +6 -6
- package/lib/smartphoto.mjs +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -224,7 +224,7 @@ Slide fields:
|
|
|
224
224
|
<tr>
|
|
225
225
|
<td>animationSpeed</td>
|
|
226
226
|
<td>animation speed (ms) when switching/opening/closing images</td>
|
|
227
|
-
<td>
|
|
227
|
+
<td>300</td>
|
|
228
228
|
</tr>
|
|
229
229
|
<tr>
|
|
230
230
|
<td>forceInterval</td>
|
|
@@ -385,7 +385,7 @@ photo.on('zoomout',function(){
|
|
|
385
385
|
<tr>
|
|
386
386
|
<td>--smartphoto-animation-speed</td>
|
|
387
387
|
<td>animation speed when switching/opening/closing images. Overridden per-instance by the <code>animationSpeed</code> JS option</td>
|
|
388
|
-
<td>
|
|
388
|
+
<td>300ms</td>
|
|
389
389
|
</tr>
|
|
390
390
|
<tr>
|
|
391
391
|
<td>--smartphoto-animation-function</td>
|
package/js/jquery-smartphoto.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SmartPhoto v2.1.
|
|
2
|
+
* SmartPhoto v2.1.15
|
|
3
3
|
* (c) appleple
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
loadOffset: 2,
|
|
164
164
|
resizeStyle: "fit",
|
|
165
165
|
lazyAttribute: "data-src",
|
|
166
|
-
animationSpeed:
|
|
166
|
+
animationSpeed: 300
|
|
167
167
|
};
|
|
168
168
|
function deepFreeze(obj) {
|
|
169
169
|
Object.keys(obj).forEach((key) => {
|
|
@@ -363,10 +363,10 @@
|
|
|
363
363
|
minY = -1 * maxY;
|
|
364
364
|
}
|
|
365
365
|
return {
|
|
366
|
-
minX: round(minX, 6)
|
|
367
|
-
minY: round(minY, 6)
|
|
368
|
-
maxX: round(maxX, 6)
|
|
369
|
-
maxY: round(maxY, 6)
|
|
366
|
+
minX: round(minX, 6) / item.scale,
|
|
367
|
+
minY: round(minY, 6) / item.scale,
|
|
368
|
+
maxX: round(maxX, 6) / item.scale,
|
|
369
|
+
maxY: round(maxY, 6) / item.scale
|
|
370
370
|
};
|
|
371
371
|
}
|
|
372
372
|
function sizeItems(items, winWidth, winHeight, headerHeight, footerHeight) {
|
|
@@ -745,7 +745,7 @@
|
|
|
745
745
|
photoSwipable = false;
|
|
746
746
|
const oldPos_ = oldPhotoPos;
|
|
747
747
|
const firstPos_ = firstPhotoPos;
|
|
748
|
-
if (oldPos_.x === firstPos_.x) {
|
|
748
|
+
if (oldPos_.x === firstPos_.x && oldPos_.y === firstPos_.y) {
|
|
749
749
|
callbacks.onPhotoDragEnd("zoom-out");
|
|
750
750
|
return;
|
|
751
751
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SmartPhoto v2.1.
|
|
2
|
+
* SmartPhoto v2.1.15
|
|
3
3
|
* (c) appleple
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
"use strict";(()=>{var K=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},Ie=()=>typeof window.webkitConvertPointFromNodeToPage=="function";function Le(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]=Le((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var Te=Le,Ce=(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)},Ae=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),r=o[0],s=o.length>1?o.slice(1).join("="):r;e[r]=decodeURIComponent(s)}return e},Z=()=>document.documentElement.clientWidth,ee=()=>{let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight},He=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var xe=t=>{let e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/);return e?[Number(e[1]),Number(e[2]),Number(e[3])]:null},Ue=.179,je=([t,e,i])=>{let[o,r,s]=[t,e,i].map(n=>{let m=n/255;return m<=.03928?m/12.92:((m+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*s},Me=t=>{let e=t.trim(),i=xe(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=xe(getComputedStyle(o).color),document.body.removeChild(o)}return i&&je(i)>Ue?"#000":"#fff"};var qe={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,useViewTransitionApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:450};function Ve(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Ve(i)}),Object.freeze(t)}function ze(t){return{options:Ve(Te({},qe,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function j(t){return t.getAttribute("data-group")||"nogroup"}function pe(t){return t.group||"nogroup"}function fe(t,e,i,o){let r=j(t),s=t.getAttribute("href"),n=t.querySelector("img"),m=s;n&&(n.getAttribute(e.lazyAttribute)?m=n.getAttribute(e.lazyAttribute):n.currentSrc?m=n.currentSrc:m=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 u=t.getAttribute("data-id");return{src:s,thumb:m,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:u||i,loaded:!1,processed:!1,element:t}}function Oe(t,e,i){var u,f,P,b,H;let o=pe(t),r=t.src,s=(u=t.thumb)!=null?u:r,n=(f=t.caption)!=null?f:null,m=(b=(P=t.alt)!=null?P:n)!=null?b:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:m,groupId:o,translateX:i*e,translateY:0,index:e,width:p?t.width:50,height:p?t.height:50,scale:1,x:0,y:0,id:(H=t.id)!=null?H:e,loaded:p,processed:!1,element:null}}function ve(t,e){t.groups.has(e.groupId)||t.groups.set(e.groupId,[]),t.groups.get(e.groupId).push(e),t.viewer.currentGroup=e.groupId}function L(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function C(t){var i;let e=L(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function we(t){let e=L(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,r=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),r!==-1&&(t.viewer.prev=r,t.viewer.showPrevArrow=!0)}function ge(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function te(t,e){let i=10**e;return Math.round(t*i)/i}function G(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Ne(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,m,p,u;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(u=(o-s)/2,m=-1*u):(u=(s-o)/2,m=-1*u),{minX:te(n,6)*e.scaleSize,minY:te(m,6)*e.scaleSize,maxX:te(p,6)*e.scaleSize,maxY:te(u,6)*e.scaleSize}}function Be(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 De(t){let e=C(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function Re(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 ye(t,e){let i=10**e;return Math.round(t*i)/i}function U(t){return{x:t.pageX,y:t.pageY}}function Xe(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var Qe=10;function _e(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ye(){return{width:Z(),height:ee()}}function Fe({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,m=null,p=null,u=null,f=0,P=null,b=!1,H=null,T=null,z=0,Y=0,V=!1,R=0,x=null,O=0,c=0;function Q(){return K()}function k(a){let{width:h,height:E}=Ye();return Ne(a,t.viewer,h,E)}function _(a){let{width:h,height:E}=Ye();return G(a,h,E,Q())}function oe(a,h){let E=C(t),y=k(E);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=y.minX:a===-1&&(t.viewer.photoPosX=y.maxX),h===1?t.viewer.photoPosY=y.minY:h===-1&&(t.viewer.photoPosY=y.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let F=setInterval(()=>{if(V||s||b||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=O,t.viewer.photoPosY+=c;let a=C(t);if(!a)return;let h=k(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,O*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,O*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,c*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,c*=-.2);let E=_e(O,c),y=E.force-t.options.registance;Math.abs(y)<.5||(O=Math.cos(E.theta)*y,c=Math.sin(E.theta)*y,e.onPhotoDragMove())},t.options.forceInterval);function W(a,h){(a>5||a<-5)&&(O+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(c+=h*.05)}function re(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||V||s||b||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",re,{signal:i});function ne(){V=!0,s=!1,b=!1;let a=Array.from(o.values());R=Xe(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function se(a){let h=U(a);s=!0,n=!0,m=h,p=h,f=Date.now(),P=a.target}function ae(a){b=!0;let h=U(a);T=h,H=h}function le(a){var h,E;try{(E=(h=a.currentTarget).setPointerCapture)==null||E.call(h,a.pointerId)}catch(y){}if(o.set(a.pointerId,U(a)),o.size>1){ne();return}if(t.viewer.scale){ae(a);return}se(a)}function he(){x===null&&(x=requestAnimationFrame(()=>{x=null,e.onGestureMove()}))}function ue(){x!==null&&(cancelAnimationFrame(x),x=null,e.onGestureMove())}function ce(){let a=Array.from(o.values()),h=Xe(a[0],a[1]),E=(h-R)/100,y=t.viewer.scaleSize,I=t.viewer.photoPosX,M=t.viewer.photoPosY;t.viewer.scaleSize+=ye(E,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<y&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-y)*I,t.viewer.photoPosY=(1+t.viewer.scaleSize-y)*M);let D=C(t);if(D){let de=_(D);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>de}R=h,he()}function d(a){let h=U(a),E=h.x-p.x,y=h.y-m.y;n&&(e.onSwipeStart(),n=!1,u=Math.abs(E)>Math.abs(y)?"horizontal":"vertical"),u==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=y,p=h,e.onSwipeMove()}function l(a){let h=U(a),E=h.x-T.x,y=h.y-T.y,I=ye(t.viewer.scaleSize*E,6),M=ye(t.viewer.scaleSize*y,6);t.viewer.photoPosX+=I,z=I,t.viewer.photoPosY+=M,Y=M,T=h,e.onPhotoDragMove()}function g(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,U(a)),V){ce();return}if(b){l(a);return}d(a)}}function v(){V=!1,ue();let a=C(t);if(!a)return;let h=_(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 w(){var Pe;s=!1;let a=m,h=p,E=Date.now(),y=r-E,I=h.x-a.x,M=h.y-a.y,D=I===0&&M===0;if(!Q()&&D){e.onTap(P);return}if(Math.abs(y)<=500&&D){e.onTap(P);return}r=E;let de=(Pe=L(t))!=null?Pe:[];if(u==="horizontal"){let $="stay",Ge=Math.max(E-f,1),Se=Math.abs(I)>=Qe&&Math.abs(I)/Ge>=t.options.swipeVelocity;(I>=t.options.swipeOffset||Se&&I>0)&&t.viewer.currentIndex!==0?$="prev":(I<=-t.options.swipeOffset||Se&&I<0)&&t.viewer.currentIndex!==de.length-1&&($="next"),e.onSwipeEnd($)}else{let $="stay";t.options.swipeBottomToClose&&M>=t.options.swipeOffset?$="close-bottom":t.options.swipeTopToClose&&M<=-t.options.swipeOffset&&($="close-top"),e.onSwipeEnd($)}}function S(){b=!1;let a=T,h=H;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let E=C(t);if(!E){e.onPhotoDragEnd(null);return}let y=k(E),I=t.options.swipeOffset*t.viewer.scaleSize,M=0,D=0;if(t.viewer.photoPosX>y.maxX?M=-1:t.viewer.photoPosX<y.minX&&(M=1),t.viewer.photoPosY>y.maxY?D=-1:t.viewer.photoPosY<y.minY&&(D=1),t.viewer.photoPosX-y.maxX>I&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(y.minX-t.viewer.photoPosX>I&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}M===0&&D===0?(O=z/5,c=Y/5):oe(M,D),e.onPhotoDragEnd(null)}function N(a){if(o.delete(a.pointerId),V){o.size<2&&v();return}if(b){S();return}s&&w()}function J(...a){for(let h of a)h.addEventListener("pointerdown",le,{signal:i}),h.addEventListener("pointermove",g,{signal:i}),h.addEventListener("pointerup",N,{signal:i}),h.addEventListener("pointercancel",N,{signal:i})}function B(){clearInterval(F),x!==null&&(cancelAnimationFrame(x),x=null)}return{attach:J,detach:B}}function ie(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function Ee(){let t=document.createElement("button");return t.type="button",t}function Je(t){return t.replace(/"/g,'\\"')}function We({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let m=document.createElement("dialog");m.className=r.smartPhoto,m.setAttribute("aria-labelledby",`smartphoto-${t}-title`),m.style.display="none",m.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let u=document.createElement("div");u.className=r.smartPhotoInner;let f=document.createElement("div");f.className=r.smartPhotoHeader;let P=document.createElement("span");P.className=r.smartPhotoCount;let b=document.createElement("h1");b.id=`smartphoto-${t}-title`,b.className=r.smartPhotoCaption,b.setAttribute("tabindex","-1");let H=document.createElement("button");H.className=r.smartPhotoDismiss,H.appendChild(ie(s.closeDialog)),H.addEventListener("click",()=>i.onDismiss(),{signal:o}),f.append(P,b,H);let T=document.createElement("div");T.className=r.smartPhotoContent,T.addEventListener("click",d=>{d.target===T&&i.onBackdropClick()},{signal:o});let z=document.createElement("ul");z.className=r.smartPhotoList,z.setAttribute("role","region"),z.setAttribute("aria-roledescription","carousel"),z.setAttribute("aria-label",s.carouselLabel),z.setAttribute("aria-live","polite"),z.setAttribute("aria-atomic","false"),u.append(f,T,z);let Y=null,V=null,R=null;if(e.arrows){Y=document.createElement("ul"),Y.className=r.smartPhotoArrows,V=document.createElement("li"),V.className=r.smartPhotoArrowLeft;let d=Ee();d.appendChild(ie(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(d),R=document.createElement("li"),R.className=r.smartPhotoArrowRight;let l=Ee();l.appendChild(ie(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),R.appendChild(l),Y.append(V,R),u.appendChild(Y)}let x=null,O=null;e.nav&&(x=document.createElement("nav"),x.className=r.smartPhotoNav,x.setAttribute("aria-label","Choose slide to display"),O=document.createElement("ul"),x.appendChild(O),u.appendChild(x)),p.appendChild(u),m.appendChild(p),n.appendChild(m);let c={dialog:m,count:P,caption:b,dismiss:H,content:T,list:z,arrows:Y,arrowLeft:V,arrowRight:R,nav:x,navList:O,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 k(d){var v,w;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let g=document.createElement("img");return g.className=r.smartPhotoImg,g.src=(v=d.src)!=null?v:"",g.alt=(w=d.alt)!=null?w:"",g.addEventListener("dragstart",S=>S.preventDefault(),{signal:o}),l.appendChild(g),{imgWrap:l,img:g}}function _(d,l){var g;c.list.replaceChildren(),(g=c.navList)==null||g.replaceChildren(),c.slides=new Map,d.forEach(v=>{var N,J;let w=document.createElement("li");w.setAttribute("role","group"),w.setAttribute("aria-roledescription","slide"),w.setAttribute("aria-label",`${v.index+1} of ${d.length}`);let S={li:w,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(v.processed){let{imgWrap:B,img:a}=k(v);w.appendChild(B),S.imgWrap=B,S.img=a}else{let B=Q();w.appendChild(B),S.loaderWrap=B}if(c.list.appendChild(w),c.slides.set(v,S),c.navList){let B=document.createElement("li"),a=Ee();a.style.backgroundImage=`url("${Je((N=v.thumb)!=null?N:"")}")`;let h=v.index;a.addEventListener("click",()=>i.onNavigate(h),{signal:o}),a.appendChild(ie(`go to ${(J=v.caption)!=null?J:""}`)),B.appendChild(a),c.navList.appendChild(B),S.navLink=a}}),W(l)}function oe(d,l){var w;if(l.imgWrap||!d.processed)return l;let{imgWrap:g,img:v}=k(d);return(w=l.loaderWrap)==null||w.replaceWith(g),l.loaderWrap=null,l.imgWrap=g,l.img=v,l}function F(d){d&&document.activeElement&&d.contains(document.activeElement)&&c.caption.focus()}function W(d){let{viewer:l}=d;c.count.textContent=`${l.currentIndex+1}/${l.total}`,c.slides.forEach((g,v)=>{var N;let w=oe(v,g),S=v.index===l.currentIndex;w.li.style.transform=`translate(${v.translateX}px,${v.translateY}px)`,w.li.classList.toggle("current",S),S?w.li.removeAttribute("aria-hidden"):w.li.setAttribute("aria-hidden","true"),S&&(c.caption.textContent=(N=v.caption)!=null?N:""),w.imgWrap&&w.img&&(w.imgWrap.style.transform=`translate(${v.x}px,${v.y}px) scale(${v.scale})`,w.img.style.width=`${v.width}px`,S||(w.img.style.transform="translate(0px,0px) scale(1)"),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"))}),c.arrowLeft&&(l.showPrevArrow?c.arrowLeft.removeAttribute("aria-hidden"):(F(c.arrowLeft),c.arrowLeft.setAttribute("aria-hidden","true"))),c.arrowRight&&(l.showNextArrow?c.arrowRight.removeAttribute("aria-hidden"):(F(c.arrowRight),c.arrowRight.setAttribute("aria-hidden","true"))),c.arrows&&(l.hideUi&&F(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.nav&&(l.hideUi&&F(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function re(d){for(let[l,g]of c.slides)if(l.index===d.viewer.currentIndex)return g;return null}function ne(d){let{viewer:l}=d,g=re(d),v=g==null?void 0:g.img;v&&(v.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,v.classList.toggle(r.smartPhotoImgOnMove,l.scale),v.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),c.nav&&(l.hideUi&&F(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.arrows&&(l.hideUi&&F(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function se(d){let{viewer:l}=d;c.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,c.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function ae(d){for(let[l,g]of c.slides){if(l.index!==d.viewer.currentIndex)continue;let{img:v,imgWrap:w}=g;if(!v||!w||!l.width||!l.scale||l.scale>=1)return;let S=v.getBoundingClientRect();v.style.width=`${l.width*l.scale}px`,w.style.transform=`translate(${l.x}px,${l.y}px) scale(1)`;let N=v.getBoundingClientRect();w.style.transform=`translate(${l.x+S.left-N.left}px,${l.y+S.top-N.top}px) scale(1)`;return}}function le(){for(let[d,l]of c.slides){let{img:g,imgWrap:v}=l;g&&v&&(v.style.transform=`translate(${d.x}px,${d.y}px) scale(${d.scale})`,g.style.width=`${d.width}px`)}}function he(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),c.imgClone=l}function ue(){var d;(d=c.imgClone)==null||d.remove(),c.imgClone=null}function ce(){n.remove()}return{root:n,refs:c,render:W,syncSlides:_,updatePhotoTransform:ne,applyViewTransitionLayout:ae,resetViewTransitionLayout:le,updateListTransform:se,showAppearEffect:he,removeAppearEffect:ue,destroy:ce}}var A=Z,X=ee;function Ke(t){return t.length>0&&t[0]instanceof Element}function Ze(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function $e(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var q=class{constructor(e,i){this.id=Ze();this.abortController=new AbortController;this.isSmartPhoneFlag=K();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.isViewTransitionActive=!1;this.pendingViewTransitionResync=!1;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.rootSelector=null;this.itemsByElement=new Map;this.handleDocumentClick=e=>{if(!(e.target instanceof Element))return;let i=e;if(i.__smartphotoClaimed)return;let o=this.findRegisteredAncestor(e.target);if(!o&&this.rootSelector&&(o=e.target.closest(this.rootSelector)),!o)return;if(e.preventDefault(),i.__smartphotoClaimed=!0,!this.itemsByElement.has(o)&&this.rootSelector){let s=j(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let r=this.itemsByElement.get(o);r&&this.openPhoto(r,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${X()}px`)};this.handleVisualViewportResize=()=>{if(this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!L(this.state))){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}};this.handleResize=()=>{if(!(!this.state.viewer.isOpen||!L(this.state))){if(this.updateViewportHeight(),this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!this.state.viewer.isOpen||!L(this.state))return;if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=A(),i=500,o=r=>{this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(e!==A()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25))},25)};o(0)};this.rootSelector=typeof e=="string"?e:null,this.state=ze(i!=null?i:{}),this.view=We({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Fe({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),document.addEventListener("click",this.handleDocumentClick,{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&this.openPhoto(o,o.element),this.updateViewportHeight(),this.applyAutoIconContrast(),window.visualViewport?window.visualViewport.addEventListener("resize",this.handleVisualViewportResize,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,r=s=>i.call(o,s);o.addEventListener(e,r,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.itemsByElement.clear(),this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){var s,n;let i=Number.parseInt(String(e),10),o=Number.isNaN(i)?0:i,r=(n=(s=L(this.state))==null?void 0:s.length)!=null?n:0;o<0||o>=r||(this.state.viewer.currentIndex=o,this.slideList())}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=$e();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=C(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=G(e,A(),X(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin"))},this.state.options.animationSpeed)))}canZoomCurrentPhoto(){let e=C(this.state);return!!e&&G(e,A(),X(),this.isSmartPhoneFlag)>1}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,u,f;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(P=>P.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,m=(f=(u=i.trigger)!=null?u:s.element)!=null?f:n;this.openPhoto(s,m)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof HTMLElement?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!Ke(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=j(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=fe(e,this.state.options,o,A());return ve(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=pe(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Oe(e,o,A());return ve(this.state,r),this.loadAllFired.delete(i),r}findRegisteredAncestor(e){let i=e;for(;i;){if(this.itemsByElement.has(i))return i;i=i.parentElement}return null}resyncGroupFromDom(e){var p;if(!this.rootSelector)return!1;let i=Array.from(document.querySelectorAll(this.rootSelector)).filter(u=>j(u)===e),o=new Set(i),r=(p=this.state.groups.get(e))!=null?p:[],s=new Map;r.forEach(u=>{u.element&&s.set(u.element,u)});let n=i.length!==r.length,m=i.map((u,f)=>{let P=s.get(u);if(P)return P.index!==f&&(n=!0,P.index=f),P;n=!0;let b=fe(u,this.state.options,f,A());return this.itemsByElement.set(u,b),b});return r.forEach(u=>{u.element&&!o.has(u.element)&&this.itemsByElement.delete(u.element)}),ge(m,A()),this.state.groups.set(e,m),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=L(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=$e();this.setHash(De(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?Re(this.state,Ae(e)):null}setPosByCurrentIndex(){let e=C(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=L(this.state);e&&(Be(e,A(),X(),this.state.options.headerHeight,this.state.options.footerHeight),this.syncFillScale())}resetTranslateCurrent(){ge(L(this.state),A())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}currentLiElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.li;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;e.style.transition=this.state.options.showAnimation===!1?"none":"",this.state.viewer.isOpen&&!e.open?(e.style.removeProperty("display"),e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&(e.close(),e.style.display="none")}commit(){this.view.render(this.state),this.view.updatePhotoTransform(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=L(this.state);this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),we(this.state)}syncFillScale(){if(this.state.options.resizeStyle!=="fill"||!this.isSmartPhoneFlag)return;let e=C(this.state);e&&(this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=G(e,A(),X(),this.isSmartPhoneFlag))}supportsViewTransition(){return this.state.options.useViewTransitionApi&&typeof document.startViewTransition=="function"&&!Ie()}openPhotoWithViewTransition(e){var n,m;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(n=e==null?void 0:e.querySelector("img"))!=null?n:null;o&&(o.style.viewTransitionName=i);let r=()=>{this.isViewTransitionActive=!1,o&&(o.style.viewTransitionName="");let p=this.currentImgElement();if(p&&(p.style.viewTransitionName=""),!this.state.viewer.isOpen){this.pendingViewTransitionResync=!1;return}if(this.pendingViewTransitionResync&&L(this.state)){this.pendingViewTransitionResync=!1,this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit();return}this.pendingViewTransitionResync=!1,this.view.resetViewTransitionLayout()},s=(m=document.startViewTransition)==null?void 0:m.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i,this.view.applyViewTransitionLayout(this.state)});s&&(this.isViewTransitionActive=!0,s.ready.catch(()=>{r()}),s.finished.then(r,r))}addAppearEffect(e,i){var T;let o=(T=e==null?void 0:e.querySelector("img"))!=null?T:null;if(!o){this.state.viewer.appear=!0;return}let r=He(o),s=o.offsetWidth,n=o.offsetHeight,m=A(),p=X(),u=p-this.state.options.headerHeight-this.state.options.footerHeight,f=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?f=p/n:f=m/s:(s>=n?i.height<u?f=i.width/s:f=u/n:i.height<u?f=i.height/n:f=u/n,s*f>m&&(f=m/s));let P=(f-1)/2*s+(m-s*f)/2,b=(f-1)/2*n+(p-n*f)/2,H=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:H||i.src||"",afterX:P,afterY:b,scale:f}}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=A(),i=X();requestAnimationFrame(()=>{if(this.state.viewer.isOpen&&!(A()===e&&X()===i)){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}})}openPhoto(e,i){let o=this.rootSelector?this.resyncGroupFromDom(e.groupId):!1;this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,(this.syncedGroupId!==e.groupId||o)&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{if(this.state.options.showAnimation===!1){i();return}let o=this.view.refs.dialog,r=C(this.state),s=r?this.currentLiElement():null,n=X(),m=this.currentImgElement(),p=null;if(m){let f=getComputedStyle(m).transform;f&&f!=="none"&&(m.style.transform=f,p=m.style.transform)}if(s&&r){let f=e==="top"?-n:n;s.style.transform=`translate(${r.translateX}px,${r.translateY+f}px)`}let u=f=>{this.finishHideEffect===u&&(f&&f.target!==o||(this.finishHideEffect=null,o.removeEventListener("transitionend",u,!0),m&&p&&m.style.transform===p&&(m.style.transform=""),i()))};this.finishHideEffect=u,o.addEventListener("transitionend",u,!0),this.scheduleTimeout(u,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(r=e.src)!=null?r:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=L(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.updateViewportHeight(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=C(this.state);this.state.viewer.onMove=!1,we(this.state),this.state.viewer.isOpen&&this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(r=>r!==o),e()},i);return this.timeouts.push(o),o}applyAutoIconContrast(){let e=this.view.refs.dialog,i=getComputedStyle(e);if(i.getPropertyValue("--smartphoto-icon-color").trim())return;let o=i.getPropertyValue("--smartphoto-backdrop-color").trim();o&&e.style.setProperty("--smartphoto-icon-color",Me(o))}fireEvent(e){Ce(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:e=>{let i=this.currentImgElement();!!i&&e instanceof Node&&i.contains(e)&&this.canZoomCurrentPhoto()?this.zoomPhoto():this.hidePhoto()},onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},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 ke=q;var be=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new ke(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],be);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&be(e)}var ct=be;})();
|
|
6
|
+
"use strict";(()=>{var K=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},Ie=()=>typeof window.webkitConvertPointFromNodeToPage=="function";function Le(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]=Le((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var Te=Le,Ce=(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)},Ae=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),r=o[0],s=o.length>1?o.slice(1).join("="):r;e[r]=decodeURIComponent(s)}return e},Z=()=>document.documentElement.clientWidth,ee=()=>{let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight},He=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var xe=t=>{let e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/);return e?[Number(e[1]),Number(e[2]),Number(e[3])]:null},Ue=.179,je=([t,e,i])=>{let[o,r,s]=[t,e,i].map(n=>{let m=n/255;return m<=.03928?m/12.92:((m+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*s},Me=t=>{let e=t.trim(),i=xe(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=xe(getComputedStyle(o).color),document.body.removeChild(o)}return i&&je(i)>Ue?"#000":"#fff"};var qe={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,useViewTransitionApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:300};function Ve(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Ve(i)}),Object.freeze(t)}function ze(t){return{options:Ve(Te({},qe,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function j(t){return t.getAttribute("data-group")||"nogroup"}function pe(t){return t.group||"nogroup"}function fe(t,e,i,o){let r=j(t),s=t.getAttribute("href"),n=t.querySelector("img"),m=s;n&&(n.getAttribute(e.lazyAttribute)?m=n.getAttribute(e.lazyAttribute):n.currentSrc?m=n.currentSrc:m=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 u=t.getAttribute("data-id");return{src:s,thumb:m,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:u||i,loaded:!1,processed:!1,element:t}}function Oe(t,e,i){var u,f,P,b,H;let o=pe(t),r=t.src,s=(u=t.thumb)!=null?u:r,n=(f=t.caption)!=null?f:null,m=(b=(P=t.alt)!=null?P:n)!=null?b:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:m,groupId:o,translateX:i*e,translateY:0,index:e,width:p?t.width:50,height:p?t.height:50,scale:1,x:0,y:0,id:(H=t.id)!=null?H:e,loaded:p,processed:!1,element:null}}function ve(t,e){t.groups.has(e.groupId)||t.groups.set(e.groupId,[]),t.groups.get(e.groupId).push(e),t.viewer.currentGroup=e.groupId}function L(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function C(t){var i;let e=L(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function we(t){let e=L(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,r=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),r!==-1&&(t.viewer.prev=r,t.viewer.showPrevArrow=!0)}function ge(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function te(t,e){let i=10**e;return Math.round(t*i)/i}function G(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Ne(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,m,p,u;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(u=(o-s)/2,m=-1*u):(u=(s-o)/2,m=-1*u),{minX:te(n,6)/t.scale,minY:te(m,6)/t.scale,maxX:te(p,6)/t.scale,maxY:te(u,6)/t.scale}}function Be(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 De(t){let e=C(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function Re(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 ye(t,e){let i=10**e;return Math.round(t*i)/i}function U(t){return{x:t.pageX,y:t.pageY}}function Xe(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var Qe=10;function _e(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ye(){return{width:Z(),height:ee()}}function Fe({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,m=null,p=null,u=null,f=0,P=null,b=!1,H=null,T=null,z=0,Y=0,V=!1,R=0,x=null,O=0,c=0;function Q(){return K()}function k(a){let{width:h,height:E}=Ye();return Ne(a,t.viewer,h,E)}function _(a){let{width:h,height:E}=Ye();return G(a,h,E,Q())}function oe(a,h){let E=C(t),y=k(E);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=y.minX:a===-1&&(t.viewer.photoPosX=y.maxX),h===1?t.viewer.photoPosY=y.minY:h===-1&&(t.viewer.photoPosY=y.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let F=setInterval(()=>{if(V||s||b||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=O,t.viewer.photoPosY+=c;let a=C(t);if(!a)return;let h=k(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,O*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,O*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,c*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,c*=-.2);let E=_e(O,c),y=E.force-t.options.registance;Math.abs(y)<.5||(O=Math.cos(E.theta)*y,c=Math.sin(E.theta)*y,e.onPhotoDragMove())},t.options.forceInterval);function W(a,h){(a>5||a<-5)&&(O+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(c+=h*.05)}function re(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||V||s||b||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",re,{signal:i});function ne(){V=!0,s=!1,b=!1;let a=Array.from(o.values());R=Xe(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function se(a){let h=U(a);s=!0,n=!0,m=h,p=h,f=Date.now(),P=a.target}function ae(a){b=!0;let h=U(a);T=h,H=h}function le(a){var h,E;try{(E=(h=a.currentTarget).setPointerCapture)==null||E.call(h,a.pointerId)}catch(y){}if(o.set(a.pointerId,U(a)),o.size>1){ne();return}if(t.viewer.scale){ae(a);return}se(a)}function he(){x===null&&(x=requestAnimationFrame(()=>{x=null,e.onGestureMove()}))}function ue(){x!==null&&(cancelAnimationFrame(x),x=null,e.onGestureMove())}function ce(){let a=Array.from(o.values()),h=Xe(a[0],a[1]),E=(h-R)/100,y=t.viewer.scaleSize,I=t.viewer.photoPosX,M=t.viewer.photoPosY;t.viewer.scaleSize+=ye(E,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<y&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-y)*I,t.viewer.photoPosY=(1+t.viewer.scaleSize-y)*M);let D=C(t);if(D){let de=_(D);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>de}R=h,he()}function d(a){let h=U(a),E=h.x-p.x,y=h.y-m.y;n&&(e.onSwipeStart(),n=!1,u=Math.abs(E)>Math.abs(y)?"horizontal":"vertical"),u==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=y,p=h,e.onSwipeMove()}function l(a){let h=U(a),E=h.x-T.x,y=h.y-T.y,I=ye(t.viewer.scaleSize*E,6),M=ye(t.viewer.scaleSize*y,6);t.viewer.photoPosX+=I,z=I,t.viewer.photoPosY+=M,Y=M,T=h,e.onPhotoDragMove()}function g(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,U(a)),V){ce();return}if(b){l(a);return}d(a)}}function v(){V=!1,ue();let a=C(t);if(!a)return;let h=_(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 w(){var Pe;s=!1;let a=m,h=p,E=Date.now(),y=r-E,I=h.x-a.x,M=h.y-a.y,D=I===0&&M===0;if(!Q()&&D){e.onTap(P);return}if(Math.abs(y)<=500&&D){e.onTap(P);return}r=E;let de=(Pe=L(t))!=null?Pe:[];if(u==="horizontal"){let $="stay",Ge=Math.max(E-f,1),Se=Math.abs(I)>=Qe&&Math.abs(I)/Ge>=t.options.swipeVelocity;(I>=t.options.swipeOffset||Se&&I>0)&&t.viewer.currentIndex!==0?$="prev":(I<=-t.options.swipeOffset||Se&&I<0)&&t.viewer.currentIndex!==de.length-1&&($="next"),e.onSwipeEnd($)}else{let $="stay";t.options.swipeBottomToClose&&M>=t.options.swipeOffset?$="close-bottom":t.options.swipeTopToClose&&M<=-t.options.swipeOffset&&($="close-top"),e.onSwipeEnd($)}}function S(){b=!1;let a=T,h=H;if(a.x===h.x&&a.y===h.y){e.onPhotoDragEnd("zoom-out");return}let E=C(t);if(!E){e.onPhotoDragEnd(null);return}let y=k(E),I=t.options.swipeOffset*t.viewer.scaleSize,M=0,D=0;if(t.viewer.photoPosX>y.maxX?M=-1:t.viewer.photoPosX<y.minX&&(M=1),t.viewer.photoPosY>y.maxY?D=-1:t.viewer.photoPosY<y.minY&&(D=1),t.viewer.photoPosX-y.maxX>I&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(y.minX-t.viewer.photoPosX>I&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}M===0&&D===0?(O=z/5,c=Y/5):oe(M,D),e.onPhotoDragEnd(null)}function N(a){if(o.delete(a.pointerId),V){o.size<2&&v();return}if(b){S();return}s&&w()}function J(...a){for(let h of a)h.addEventListener("pointerdown",le,{signal:i}),h.addEventListener("pointermove",g,{signal:i}),h.addEventListener("pointerup",N,{signal:i}),h.addEventListener("pointercancel",N,{signal:i})}function B(){clearInterval(F),x!==null&&(cancelAnimationFrame(x),x=null)}return{attach:J,detach:B}}function ie(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function Ee(){let t=document.createElement("button");return t.type="button",t}function Je(t){return t.replace(/"/g,'\\"')}function We({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let m=document.createElement("dialog");m.className=r.smartPhoto,m.setAttribute("aria-labelledby",`smartphoto-${t}-title`),m.style.display="none",m.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let u=document.createElement("div");u.className=r.smartPhotoInner;let f=document.createElement("div");f.className=r.smartPhotoHeader;let P=document.createElement("span");P.className=r.smartPhotoCount;let b=document.createElement("h1");b.id=`smartphoto-${t}-title`,b.className=r.smartPhotoCaption,b.setAttribute("tabindex","-1");let H=document.createElement("button");H.className=r.smartPhotoDismiss,H.appendChild(ie(s.closeDialog)),H.addEventListener("click",()=>i.onDismiss(),{signal:o}),f.append(P,b,H);let T=document.createElement("div");T.className=r.smartPhotoContent,T.addEventListener("click",d=>{d.target===T&&i.onBackdropClick()},{signal:o});let z=document.createElement("ul");z.className=r.smartPhotoList,z.setAttribute("role","region"),z.setAttribute("aria-roledescription","carousel"),z.setAttribute("aria-label",s.carouselLabel),z.setAttribute("aria-live","polite"),z.setAttribute("aria-atomic","false"),u.append(f,T,z);let Y=null,V=null,R=null;if(e.arrows){Y=document.createElement("ul"),Y.className=r.smartPhotoArrows,V=document.createElement("li"),V.className=r.smartPhotoArrowLeft;let d=Ee();d.appendChild(ie(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(d),R=document.createElement("li"),R.className=r.smartPhotoArrowRight;let l=Ee();l.appendChild(ie(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),R.appendChild(l),Y.append(V,R),u.appendChild(Y)}let x=null,O=null;e.nav&&(x=document.createElement("nav"),x.className=r.smartPhotoNav,x.setAttribute("aria-label","Choose slide to display"),O=document.createElement("ul"),x.appendChild(O),u.appendChild(x)),p.appendChild(u),m.appendChild(p),n.appendChild(m);let c={dialog:m,count:P,caption:b,dismiss:H,content:T,list:z,arrows:Y,arrowLeft:V,arrowRight:R,nav:x,navList:O,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 k(d){var v,w;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let g=document.createElement("img");return g.className=r.smartPhotoImg,g.src=(v=d.src)!=null?v:"",g.alt=(w=d.alt)!=null?w:"",g.addEventListener("dragstart",S=>S.preventDefault(),{signal:o}),l.appendChild(g),{imgWrap:l,img:g}}function _(d,l){var g;c.list.replaceChildren(),(g=c.navList)==null||g.replaceChildren(),c.slides=new Map,d.forEach(v=>{var N,J;let w=document.createElement("li");w.setAttribute("role","group"),w.setAttribute("aria-roledescription","slide"),w.setAttribute("aria-label",`${v.index+1} of ${d.length}`);let S={li:w,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(v.processed){let{imgWrap:B,img:a}=k(v);w.appendChild(B),S.imgWrap=B,S.img=a}else{let B=Q();w.appendChild(B),S.loaderWrap=B}if(c.list.appendChild(w),c.slides.set(v,S),c.navList){let B=document.createElement("li"),a=Ee();a.style.backgroundImage=`url("${Je((N=v.thumb)!=null?N:"")}")`;let h=v.index;a.addEventListener("click",()=>i.onNavigate(h),{signal:o}),a.appendChild(ie(`go to ${(J=v.caption)!=null?J:""}`)),B.appendChild(a),c.navList.appendChild(B),S.navLink=a}}),W(l)}function oe(d,l){var w;if(l.imgWrap||!d.processed)return l;let{imgWrap:g,img:v}=k(d);return(w=l.loaderWrap)==null||w.replaceWith(g),l.loaderWrap=null,l.imgWrap=g,l.img=v,l}function F(d){d&&document.activeElement&&d.contains(document.activeElement)&&c.caption.focus()}function W(d){let{viewer:l}=d;c.count.textContent=`${l.currentIndex+1}/${l.total}`,c.slides.forEach((g,v)=>{var N;let w=oe(v,g),S=v.index===l.currentIndex;w.li.style.transform=`translate(${v.translateX}px,${v.translateY}px)`,w.li.classList.toggle("current",S),S?w.li.removeAttribute("aria-hidden"):w.li.setAttribute("aria-hidden","true"),S&&(c.caption.textContent=(N=v.caption)!=null?N:""),w.imgWrap&&w.img&&(w.imgWrap.style.transform=`translate(${v.x}px,${v.y}px) scale(${v.scale})`,w.img.style.width=`${v.width}px`,S||(w.img.style.transform="translate(0px,0px) scale(1)"),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"))}),c.arrowLeft&&(l.showPrevArrow?c.arrowLeft.removeAttribute("aria-hidden"):(F(c.arrowLeft),c.arrowLeft.setAttribute("aria-hidden","true"))),c.arrowRight&&(l.showNextArrow?c.arrowRight.removeAttribute("aria-hidden"):(F(c.arrowRight),c.arrowRight.setAttribute("aria-hidden","true"))),c.arrows&&(l.hideUi&&F(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.nav&&(l.hideUi&&F(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function re(d){for(let[l,g]of c.slides)if(l.index===d.viewer.currentIndex)return g;return null}function ne(d){let{viewer:l}=d,g=re(d),v=g==null?void 0:g.img;v&&(v.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,v.classList.toggle(r.smartPhotoImgOnMove,l.scale),v.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),c.nav&&(l.hideUi&&F(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.arrows&&(l.hideUi&&F(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function se(d){let{viewer:l}=d;c.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,c.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function ae(d){for(let[l,g]of c.slides){if(l.index!==d.viewer.currentIndex)continue;let{img:v,imgWrap:w}=g;if(!v||!w||!l.width||!l.scale||l.scale>=1)return;let S=v.getBoundingClientRect();v.style.width=`${l.width*l.scale}px`,w.style.transform=`translate(${l.x}px,${l.y}px) scale(1)`;let N=v.getBoundingClientRect();w.style.transform=`translate(${l.x+S.left-N.left}px,${l.y+S.top-N.top}px) scale(1)`;return}}function le(){for(let[d,l]of c.slides){let{img:g,imgWrap:v}=l;g&&v&&(v.style.transform=`translate(${d.x}px,${d.y}px) scale(${d.scale})`,g.style.width=`${d.width}px`)}}function he(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),c.imgClone=l}function ue(){var d;(d=c.imgClone)==null||d.remove(),c.imgClone=null}function ce(){n.remove()}return{root:n,refs:c,render:W,syncSlides:_,updatePhotoTransform:ne,applyViewTransitionLayout:ae,resetViewTransitionLayout:le,updateListTransform:se,showAppearEffect:he,removeAppearEffect:ue,destroy:ce}}var A=Z,X=ee;function Ke(t){return t.length>0&&t[0]instanceof Element}function Ze(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function $e(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var q=class{constructor(e,i){this.id=Ze();this.abortController=new AbortController;this.isSmartPhoneFlag=K();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.isViewTransitionActive=!1;this.pendingViewTransitionResync=!1;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.rootSelector=null;this.itemsByElement=new Map;this.handleDocumentClick=e=>{if(!(e.target instanceof Element))return;let i=e;if(i.__smartphotoClaimed)return;let o=this.findRegisteredAncestor(e.target);if(!o&&this.rootSelector&&(o=e.target.closest(this.rootSelector)),!o)return;if(e.preventDefault(),i.__smartphotoClaimed=!0,!this.itemsByElement.has(o)&&this.rootSelector){let s=j(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let r=this.itemsByElement.get(o);r&&this.openPhoto(r,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${X()}px`)};this.handleVisualViewportResize=()=>{if(this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!L(this.state))){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}};this.handleResize=()=>{if(!(!this.state.viewer.isOpen||!L(this.state))){if(this.updateViewportHeight(),this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!this.state.viewer.isOpen||!L(this.state))return;if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=A(),i=500,o=r=>{this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(e!==A()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25))},25)};o(0)};this.rootSelector=typeof e=="string"?e:null,this.state=ze(i!=null?i:{}),this.view=We({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Fe({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),document.addEventListener("click",this.handleDocumentClick,{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&this.openPhoto(o,o.element),this.updateViewportHeight(),this.applyAutoIconContrast(),window.visualViewport?window.visualViewport.addEventListener("resize",this.handleVisualViewportResize,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,r=s=>i.call(o,s);o.addEventListener(e,r,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.itemsByElement.clear(),this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){var s,n;let i=Number.parseInt(String(e),10),o=Number.isNaN(i)?0:i,r=(n=(s=L(this.state))==null?void 0:s.length)!=null?n:0;o<0||o>=r||(this.state.viewer.currentIndex=o,this.slideList())}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=$e();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=C(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=G(e,A(),X(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin"))},this.state.options.animationSpeed)))}canZoomCurrentPhoto(){let e=C(this.state);return!!e&&G(e,A(),X(),this.isSmartPhoneFlag)>1}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,u,f;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(P=>P.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,m=(f=(u=i.trigger)!=null?u:s.element)!=null?f:n;this.openPhoto(s,m)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof HTMLElement?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!Ke(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=j(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=fe(e,this.state.options,o,A());return ve(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=pe(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Oe(e,o,A());return ve(this.state,r),this.loadAllFired.delete(i),r}findRegisteredAncestor(e){let i=e;for(;i;){if(this.itemsByElement.has(i))return i;i=i.parentElement}return null}resyncGroupFromDom(e){var p;if(!this.rootSelector)return!1;let i=Array.from(document.querySelectorAll(this.rootSelector)).filter(u=>j(u)===e),o=new Set(i),r=(p=this.state.groups.get(e))!=null?p:[],s=new Map;r.forEach(u=>{u.element&&s.set(u.element,u)});let n=i.length!==r.length,m=i.map((u,f)=>{let P=s.get(u);if(P)return P.index!==f&&(n=!0,P.index=f),P;n=!0;let b=fe(u,this.state.options,f,A());return this.itemsByElement.set(u,b),b});return r.forEach(u=>{u.element&&!o.has(u.element)&&this.itemsByElement.delete(u.element)}),ge(m,A()),this.state.groups.set(e,m),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=L(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=$e();this.setHash(De(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?Re(this.state,Ae(e)):null}setPosByCurrentIndex(){let e=C(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=L(this.state);e&&(Be(e,A(),X(),this.state.options.headerHeight,this.state.options.footerHeight),this.syncFillScale())}resetTranslateCurrent(){ge(L(this.state),A())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}currentLiElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.li;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;e.style.transition=this.state.options.showAnimation===!1?"none":"",this.state.viewer.isOpen&&!e.open?(e.style.removeProperty("display"),e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&(e.close(),e.style.display="none")}commit(){this.view.render(this.state),this.view.updatePhotoTransform(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=L(this.state);this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),we(this.state)}syncFillScale(){if(this.state.options.resizeStyle!=="fill"||!this.isSmartPhoneFlag)return;let e=C(this.state);e&&(this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=G(e,A(),X(),this.isSmartPhoneFlag))}supportsViewTransition(){return this.state.options.useViewTransitionApi&&typeof document.startViewTransition=="function"&&!Ie()}openPhotoWithViewTransition(e){var n,m;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(n=e==null?void 0:e.querySelector("img"))!=null?n:null;o&&(o.style.viewTransitionName=i);let r=()=>{this.isViewTransitionActive=!1,o&&(o.style.viewTransitionName="");let p=this.currentImgElement();if(p&&(p.style.viewTransitionName=""),!this.state.viewer.isOpen){this.pendingViewTransitionResync=!1;return}if(this.pendingViewTransitionResync&&L(this.state)){this.pendingViewTransitionResync=!1,this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit();return}this.pendingViewTransitionResync=!1,this.view.resetViewTransitionLayout()},s=(m=document.startViewTransition)==null?void 0:m.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i,this.view.applyViewTransitionLayout(this.state)});s&&(this.isViewTransitionActive=!0,s.ready.catch(()=>{r()}),s.finished.then(r,r))}addAppearEffect(e,i){var T;let o=(T=e==null?void 0:e.querySelector("img"))!=null?T:null;if(!o){this.state.viewer.appear=!0;return}let r=He(o),s=o.offsetWidth,n=o.offsetHeight,m=A(),p=X(),u=p-this.state.options.headerHeight-this.state.options.footerHeight,f=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?f=p/n:f=m/s:(s>=n?i.height<u?f=i.width/s:f=u/n:i.height<u?f=i.height/n:f=u/n,s*f>m&&(f=m/s));let P=(f-1)/2*s+(m-s*f)/2,b=(f-1)/2*n+(p-n*f)/2,H=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:H||i.src||"",afterX:P,afterY:b,scale:f}}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=A(),i=X();requestAnimationFrame(()=>{if(this.state.viewer.isOpen&&!(A()===e&&X()===i)){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}})}openPhoto(e,i){let o=this.rootSelector?this.resyncGroupFromDom(e.groupId):!1;this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,(this.syncedGroupId!==e.groupId||o)&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{if(this.state.options.showAnimation===!1){i();return}let o=this.view.refs.dialog,r=C(this.state),s=r?this.currentLiElement():null,n=X(),m=this.currentImgElement(),p=null;if(m){let f=getComputedStyle(m).transform;f&&f!=="none"&&(m.style.transform=f,p=m.style.transform)}if(s&&r){let f=e==="top"?-n:n;s.style.transform=`translate(${r.translateX}px,${r.translateY+f}px)`}let u=f=>{this.finishHideEffect===u&&(f&&f.target!==o||(this.finishHideEffect=null,o.removeEventListener("transitionend",u,!0),m&&p&&m.style.transform===p&&(m.style.transform=""),i()))};this.finishHideEffect=u,o.addEventListener("transitionend",u,!0),this.scheduleTimeout(u,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(r=e.src)!=null?r:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=L(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.updateViewportHeight(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=C(this.state);this.state.viewer.onMove=!1,we(this.state),this.state.viewer.isOpen&&this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(r=>r!==o),e()},i);return this.timeouts.push(o),o}applyAutoIconContrast(){let e=this.view.refs.dialog,i=getComputedStyle(e);if(i.getPropertyValue("--smartphoto-icon-color").trim())return;let o=i.getPropertyValue("--smartphoto-backdrop-color").trim();o&&e.style.setProperty("--smartphoto-icon-color",Me(o))}fireEvent(e){Ce(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:e=>{let i=this.currentImgElement();!!i&&e instanceof Node&&i.contains(e)&&this.canZoomCurrentPhoto()?this.zoomPhoto():this.hidePhoto()},onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},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 ke=q;var be=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new ke(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],be);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&be(e)}var ct=be;})();
|
package/js/smartphoto.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SmartPhoto v2.1.
|
|
2
|
+
* SmartPhoto v2.1.15
|
|
3
3
|
* (c) appleple
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -187,7 +187,7 @@ var SmartPhoto = (() => {
|
|
|
187
187
|
loadOffset: 2,
|
|
188
188
|
resizeStyle: "fit",
|
|
189
189
|
lazyAttribute: "data-src",
|
|
190
|
-
animationSpeed:
|
|
190
|
+
animationSpeed: 300
|
|
191
191
|
};
|
|
192
192
|
function deepFreeze(obj) {
|
|
193
193
|
Object.keys(obj).forEach((key) => {
|
|
@@ -387,10 +387,10 @@ var SmartPhoto = (() => {
|
|
|
387
387
|
minY = -1 * maxY;
|
|
388
388
|
}
|
|
389
389
|
return {
|
|
390
|
-
minX: round(minX, 6)
|
|
391
|
-
minY: round(minY, 6)
|
|
392
|
-
maxX: round(maxX, 6)
|
|
393
|
-
maxY: round(maxY, 6)
|
|
390
|
+
minX: round(minX, 6) / item.scale,
|
|
391
|
+
minY: round(minY, 6) / item.scale,
|
|
392
|
+
maxX: round(maxX, 6) / item.scale,
|
|
393
|
+
maxY: round(maxY, 6) / item.scale
|
|
394
394
|
};
|
|
395
395
|
}
|
|
396
396
|
function sizeItems(items, winWidth, winHeight, headerHeight, footerHeight) {
|
|
@@ -769,7 +769,7 @@ var SmartPhoto = (() => {
|
|
|
769
769
|
photoSwipable = false;
|
|
770
770
|
const oldPos_ = oldPhotoPos;
|
|
771
771
|
const firstPos_ = firstPhotoPos;
|
|
772
|
-
if (oldPos_.x === firstPos_.x) {
|
|
772
|
+
if (oldPos_.x === firstPos_.x && oldPos_.y === firstPos_.y) {
|
|
773
773
|
callbacks.onPhotoDragEnd("zoom-out");
|
|
774
774
|
return;
|
|
775
775
|
}
|
package/js/smartphoto.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SmartPhoto v2.1.
|
|
2
|
+
* SmartPhoto v2.1.15
|
|
3
3
|
* (c) appleple
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var SmartPhoto=(()=>{var me=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var _e=Object.prototype.hasOwnProperty;var qe=(t,e)=>{for(var i in e)me(t,i,{get:e[i],enumerable:!0})},je=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ue(e))!_e.call(t,r)&&r!==i&&me(t,r,{get:()=>e[r],enumerable:!(o=ke(e,r))||o.enumerable});return t};var Ke=t=>je(me({},"__esModule",{value:!0}),t);var st={};qe(st,{default:()=>nt});var Z=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},Ie=()=>typeof window.webkitConvertPointFromNodeToPage=="function";function Le(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]=Le((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var Te=Le,Ce=(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)},Ae=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},J=()=>document.documentElement.clientWidth,ee=()=>{let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight},He=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var xe=t=>{let e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/);return e?[Number(e[1]),Number(e[2]),Number(e[3])]:null},Qe=.179,Ze=([t,e,i])=>{let[o,r,s]=[t,e,i].map(n=>{let m=n/255;return m<=.03928?m/12.92:((m+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*s},Me=t=>{let e=t.trim(),i=xe(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=xe(getComputedStyle(o).color),document.body.removeChild(o)}return i&&Ze(i)>Qe?"#000":"#fff"};var Je={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,useViewTransitionApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:450};function Ve(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Ve(i)}),Object.freeze(t)}function ze(t){return{options:Ve(Te({},Je,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function _(t){return t.getAttribute("data-group")||"nogroup"}function fe(t){return t.group||"nogroup"}function ve(t,e,i,o){let r=_(t),s=t.getAttribute("href"),n=t.querySelector("img"),m=s;n&&(n.getAttribute(e.lazyAttribute)?m=n.getAttribute(e.lazyAttribute):n.currentSrc?m=n.currentSrc:m=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 u=t.getAttribute("data-id");return{src:s,thumb:m,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:u||i,loaded:!1,processed:!1,element:t}}function Oe(t,e,i){var u,f,P,b,H;let o=fe(t),r=t.src,s=(u=t.thumb)!=null?u:r,n=(f=t.caption)!=null?f:null,m=(b=(P=t.alt)!=null?P:n)!=null?b:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:m,groupId:o,translateX:i*e,translateY:0,index:e,width:p?t.width:50,height:p?t.height:50,scale:1,x:0,y:0,id:(H=t.id)!=null?H:e,loaded:p,processed:!1,element:null}}function we(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 L(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function C(t){var i;let e=L(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function ge(t){let e=L(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 Ee(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function te(t,e){let i=10**e;return Math.round(t*i)/i}function k(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Ne(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,m,p,u;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(u=(o-s)/2,m=-1*u):(u=(s-o)/2,m=-1*u),{minX:te(n,6)*e.scaleSize,minY:te(m,6)*e.scaleSize,maxX:te(p,6)*e.scaleSize,maxY:te(u,6)*e.scaleSize}}function Be(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 De(t){let e=C(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function Re(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 ye(t,e){let i=10**e;return Math.round(t*i)/i}function U(t){return{x:t.pageX,y:t.pageY}}function Xe(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var et=10;function tt(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ye(){return{width:J(),height:ee()}}function Fe({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,m=null,p=null,u=null,f=0,P=null,b=!1,H=null,T=null,z=0,Y=0,V=!1,R=0,x=null,O=0,c=0;function j(){return Z()}function $(a){let{width:h,height:y}=Ye();return Ne(a,t.viewer,h,y)}function K(a){let{width:h,height:y}=Ye();return k(a,h,y,j())}function oe(a,h){let y=C(t),E=$(y);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=E.minX:a===-1&&(t.viewer.photoPosX=E.maxX),h===1?t.viewer.photoPosY=E.minY:h===-1&&(t.viewer.photoPosY=E.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let F=setInterval(()=>{if(V||s||b||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=O,t.viewer.photoPosY+=c;let a=C(t);if(!a)return;let h=$(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,O*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,O*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,c*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,c*=-.2);let y=tt(O,c),E=y.force-t.options.registance;Math.abs(E)<.5||(O=Math.cos(y.theta)*E,c=Math.sin(y.theta)*E,e.onPhotoDragMove())},t.options.forceInterval);function W(a,h){(a>5||a<-5)&&(O+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(c+=h*.05)}function re(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||V||s||b||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",re,{signal:i});function ne(){V=!0,s=!1,b=!1;let a=Array.from(o.values());R=Xe(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function se(a){let h=U(a);s=!0,n=!0,m=h,p=h,f=Date.now(),P=a.target}function ae(a){b=!0;let h=U(a);T=h,H=h}function le(a){var h,y;try{(y=(h=a.currentTarget).setPointerCapture)==null||y.call(h,a.pointerId)}catch(E){}if(o.set(a.pointerId,U(a)),o.size>1){ne();return}if(t.viewer.scale){ae(a);return}se(a)}function he(){x===null&&(x=requestAnimationFrame(()=>{x=null,e.onGestureMove()}))}function ue(){x!==null&&(cancelAnimationFrame(x),x=null,e.onGestureMove())}function ce(){let a=Array.from(o.values()),h=Xe(a[0],a[1]),y=(h-R)/100,E=t.viewer.scaleSize,I=t.viewer.photoPosX,M=t.viewer.photoPosY;t.viewer.scaleSize+=ye(y,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<E&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-E)*I,t.viewer.photoPosY=(1+t.viewer.scaleSize-E)*M);let D=C(t);if(D){let de=K(D);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>de}R=h,he()}function d(a){let h=U(a),y=h.x-p.x,E=h.y-m.y;n&&(e.onSwipeStart(),n=!1,u=Math.abs(y)>Math.abs(E)?"horizontal":"vertical"),u==="horizontal"?t.viewer.translateX+=y:t.viewer.translateY=E,p=h,e.onSwipeMove()}function l(a){let h=U(a),y=h.x-T.x,E=h.y-T.y,I=ye(t.viewer.scaleSize*y,6),M=ye(t.viewer.scaleSize*E,6);t.viewer.photoPosX+=I,z=I,t.viewer.photoPosY+=M,Y=M,T=h,e.onPhotoDragMove()}function g(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,U(a)),V){ce();return}if(b){l(a);return}d(a)}}function v(){V=!1,ue();let a=C(t);if(!a)return;let h=K(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 w(){var Pe;s=!1;let a=m,h=p,y=Date.now(),E=r-y,I=h.x-a.x,M=h.y-a.y,D=I===0&&M===0;if(!j()&&D){e.onTap(P);return}if(Math.abs(E)<=500&&D){e.onTap(P);return}r=y;let de=(Pe=L(t))!=null?Pe:[];if(u==="horizontal"){let G="stay",$e=Math.max(y-f,1),Se=Math.abs(I)>=et&&Math.abs(I)/$e>=t.options.swipeVelocity;(I>=t.options.swipeOffset||Se&&I>0)&&t.viewer.currentIndex!==0?G="prev":(I<=-t.options.swipeOffset||Se&&I<0)&&t.viewer.currentIndex!==de.length-1&&(G="next"),e.onSwipeEnd(G)}else{let G="stay";t.options.swipeBottomToClose&&M>=t.options.swipeOffset?G="close-bottom":t.options.swipeTopToClose&&M<=-t.options.swipeOffset&&(G="close-top"),e.onSwipeEnd(G)}}function S(){b=!1;let a=T,h=H;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let y=C(t);if(!y){e.onPhotoDragEnd(null);return}let E=$(y),I=t.options.swipeOffset*t.viewer.scaleSize,M=0,D=0;if(t.viewer.photoPosX>E.maxX?M=-1:t.viewer.photoPosX<E.minX&&(M=1),t.viewer.photoPosY>E.maxY?D=-1:t.viewer.photoPosY<E.minY&&(D=1),t.viewer.photoPosX-E.maxX>I&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(E.minX-t.viewer.photoPosX>I&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}M===0&&D===0?(O=z/5,c=Y/5):oe(M,D),e.onPhotoDragEnd(null)}function N(a){if(o.delete(a.pointerId),V){o.size<2&&v();return}if(b){S();return}s&&w()}function Q(...a){for(let h of a)h.addEventListener("pointerdown",le,{signal:i}),h.addEventListener("pointermove",g,{signal:i}),h.addEventListener("pointerup",N,{signal:i}),h.addEventListener("pointercancel",N,{signal:i})}function B(){clearInterval(F),x!==null&&(cancelAnimationFrame(x),x=null)}return{attach:Q,detach:B}}function ie(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function be(){let t=document.createElement("button");return t.type="button",t}function it(t){return t.replace(/"/g,'\\"')}function We({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let m=document.createElement("dialog");m.className=r.smartPhoto,m.setAttribute("aria-labelledby",`smartphoto-${t}-title`),m.style.display="none",m.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let u=document.createElement("div");u.className=r.smartPhotoInner;let f=document.createElement("div");f.className=r.smartPhotoHeader;let P=document.createElement("span");P.className=r.smartPhotoCount;let b=document.createElement("h1");b.id=`smartphoto-${t}-title`,b.className=r.smartPhotoCaption,b.setAttribute("tabindex","-1");let H=document.createElement("button");H.className=r.smartPhotoDismiss,H.appendChild(ie(s.closeDialog)),H.addEventListener("click",()=>i.onDismiss(),{signal:o}),f.append(P,b,H);let T=document.createElement("div");T.className=r.smartPhotoContent,T.addEventListener("click",d=>{d.target===T&&i.onBackdropClick()},{signal:o});let z=document.createElement("ul");z.className=r.smartPhotoList,z.setAttribute("role","region"),z.setAttribute("aria-roledescription","carousel"),z.setAttribute("aria-label",s.carouselLabel),z.setAttribute("aria-live","polite"),z.setAttribute("aria-atomic","false"),u.append(f,T,z);let Y=null,V=null,R=null;if(e.arrows){Y=document.createElement("ul"),Y.className=r.smartPhotoArrows,V=document.createElement("li"),V.className=r.smartPhotoArrowLeft;let d=be();d.appendChild(ie(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(d),R=document.createElement("li"),R.className=r.smartPhotoArrowRight;let l=be();l.appendChild(ie(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),R.appendChild(l),Y.append(V,R),u.appendChild(Y)}let x=null,O=null;e.nav&&(x=document.createElement("nav"),x.className=r.smartPhotoNav,x.setAttribute("aria-label","Choose slide to display"),O=document.createElement("ul"),x.appendChild(O),u.appendChild(x)),p.appendChild(u),m.appendChild(p),n.appendChild(m);let c={dialog:m,count:P,caption:b,dismiss:H,content:T,list:z,arrows:Y,arrowLeft:V,arrowRight:R,nav:x,navList:O,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 $(d){var v,w;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let g=document.createElement("img");return g.className=r.smartPhotoImg,g.src=(v=d.src)!=null?v:"",g.alt=(w=d.alt)!=null?w:"",g.addEventListener("dragstart",S=>S.preventDefault(),{signal:o}),l.appendChild(g),{imgWrap:l,img:g}}function K(d,l){var g;c.list.replaceChildren(),(g=c.navList)==null||g.replaceChildren(),c.slides=new Map,d.forEach(v=>{var N,Q;let w=document.createElement("li");w.setAttribute("role","group"),w.setAttribute("aria-roledescription","slide"),w.setAttribute("aria-label",`${v.index+1} of ${d.length}`);let S={li:w,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(v.processed){let{imgWrap:B,img:a}=$(v);w.appendChild(B),S.imgWrap=B,S.img=a}else{let B=j();w.appendChild(B),S.loaderWrap=B}if(c.list.appendChild(w),c.slides.set(v,S),c.navList){let B=document.createElement("li"),a=be();a.style.backgroundImage=`url("${it((N=v.thumb)!=null?N:"")}")`;let h=v.index;a.addEventListener("click",()=>i.onNavigate(h),{signal:o}),a.appendChild(ie(`go to ${(Q=v.caption)!=null?Q:""}`)),B.appendChild(a),c.navList.appendChild(B),S.navLink=a}}),W(l)}function oe(d,l){var w;if(l.imgWrap||!d.processed)return l;let{imgWrap:g,img:v}=$(d);return(w=l.loaderWrap)==null||w.replaceWith(g),l.loaderWrap=null,l.imgWrap=g,l.img=v,l}function F(d){d&&document.activeElement&&d.contains(document.activeElement)&&c.caption.focus()}function W(d){let{viewer:l}=d;c.count.textContent=`${l.currentIndex+1}/${l.total}`,c.slides.forEach((g,v)=>{var N;let w=oe(v,g),S=v.index===l.currentIndex;w.li.style.transform=`translate(${v.translateX}px,${v.translateY}px)`,w.li.classList.toggle("current",S),S?w.li.removeAttribute("aria-hidden"):w.li.setAttribute("aria-hidden","true"),S&&(c.caption.textContent=(N=v.caption)!=null?N:""),w.imgWrap&&w.img&&(w.imgWrap.style.transform=`translate(${v.x}px,${v.y}px) scale(${v.scale})`,w.img.style.width=`${v.width}px`,S||(w.img.style.transform="translate(0px,0px) scale(1)"),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"))}),c.arrowLeft&&(l.showPrevArrow?c.arrowLeft.removeAttribute("aria-hidden"):(F(c.arrowLeft),c.arrowLeft.setAttribute("aria-hidden","true"))),c.arrowRight&&(l.showNextArrow?c.arrowRight.removeAttribute("aria-hidden"):(F(c.arrowRight),c.arrowRight.setAttribute("aria-hidden","true"))),c.arrows&&(l.hideUi&&F(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.nav&&(l.hideUi&&F(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function re(d){for(let[l,g]of c.slides)if(l.index===d.viewer.currentIndex)return g;return null}function ne(d){let{viewer:l}=d,g=re(d),v=g==null?void 0:g.img;v&&(v.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,v.classList.toggle(r.smartPhotoImgOnMove,l.scale),v.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),c.nav&&(l.hideUi&&F(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.arrows&&(l.hideUi&&F(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function se(d){let{viewer:l}=d;c.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,c.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function ae(d){for(let[l,g]of c.slides){if(l.index!==d.viewer.currentIndex)continue;let{img:v,imgWrap:w}=g;if(!v||!w||!l.width||!l.scale||l.scale>=1)return;let S=v.getBoundingClientRect();v.style.width=`${l.width*l.scale}px`,w.style.transform=`translate(${l.x}px,${l.y}px) scale(1)`;let N=v.getBoundingClientRect();w.style.transform=`translate(${l.x+S.left-N.left}px,${l.y+S.top-N.top}px) scale(1)`;return}}function le(){for(let[d,l]of c.slides){let{img:g,imgWrap:v}=l;g&&v&&(v.style.transform=`translate(${d.x}px,${d.y}px) scale(${d.scale})`,g.style.width=`${d.width}px`)}}function he(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),c.imgClone=l}function ue(){var d;(d=c.imgClone)==null||d.remove(),c.imgClone=null}function ce(){n.remove()}return{root:n,refs:c,render:W,syncSlides:K,updatePhotoTransform:ne,applyViewTransitionLayout:ae,resetViewTransitionLayout:le,updateListTransform:se,showAppearEffect:he,removeAppearEffect:ue,destroy:ce}}var A=J,X=ee;function ot(t){return t.length>0&&t[0]instanceof Element}function rt(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function Ge(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var q=class{constructor(e,i){this.id=rt();this.abortController=new AbortController;this.isSmartPhoneFlag=Z();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.isViewTransitionActive=!1;this.pendingViewTransitionResync=!1;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.rootSelector=null;this.itemsByElement=new Map;this.handleDocumentClick=e=>{if(!(e.target instanceof Element))return;let i=e;if(i.__smartphotoClaimed)return;let o=this.findRegisteredAncestor(e.target);if(!o&&this.rootSelector&&(o=e.target.closest(this.rootSelector)),!o)return;if(e.preventDefault(),i.__smartphotoClaimed=!0,!this.itemsByElement.has(o)&&this.rootSelector){let s=_(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let r=this.itemsByElement.get(o);r&&this.openPhoto(r,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${X()}px`)};this.handleVisualViewportResize=()=>{if(this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!L(this.state))){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}};this.handleResize=()=>{if(!(!this.state.viewer.isOpen||!L(this.state))){if(this.updateViewportHeight(),this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!this.state.viewer.isOpen||!L(this.state))return;if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=A(),i=500,o=r=>{this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(e!==A()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25))},25)};o(0)};this.rootSelector=typeof e=="string"?e:null,this.state=ze(i!=null?i:{}),this.view=We({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Fe({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),document.addEventListener("click",this.handleDocumentClick,{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&this.openPhoto(o,o.element),this.updateViewportHeight(),this.applyAutoIconContrast(),window.visualViewport?window.visualViewport.addEventListener("resize",this.handleVisualViewportResize,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,r=s=>i.call(o,s);o.addEventListener(e,r,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.itemsByElement.clear(),this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){var s,n;let i=Number.parseInt(String(e),10),o=Number.isNaN(i)?0:i,r=(n=(s=L(this.state))==null?void 0:s.length)!=null?n:0;o<0||o>=r||(this.state.viewer.currentIndex=o,this.slideList())}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=Ge();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=C(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=k(e,A(),X(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin"))},this.state.options.animationSpeed)))}canZoomCurrentPhoto(){let e=C(this.state);return!!e&&k(e,A(),X(),this.isSmartPhoneFlag)>1}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,u,f;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(P=>P.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,m=(f=(u=i.trigger)!=null?u:s.element)!=null?f:n;this.openPhoto(s,m)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof HTMLElement?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!ot(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=_(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=ve(e,this.state.options,o,A());return we(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=fe(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Oe(e,o,A());return we(this.state,r),this.loadAllFired.delete(i),r}findRegisteredAncestor(e){let i=e;for(;i;){if(this.itemsByElement.has(i))return i;i=i.parentElement}return null}resyncGroupFromDom(e){var p;if(!this.rootSelector)return!1;let i=Array.from(document.querySelectorAll(this.rootSelector)).filter(u=>_(u)===e),o=new Set(i),r=(p=this.state.groups.get(e))!=null?p:[],s=new Map;r.forEach(u=>{u.element&&s.set(u.element,u)});let n=i.length!==r.length,m=i.map((u,f)=>{let P=s.get(u);if(P)return P.index!==f&&(n=!0,P.index=f),P;n=!0;let b=ve(u,this.state.options,f,A());return this.itemsByElement.set(u,b),b});return r.forEach(u=>{u.element&&!o.has(u.element)&&this.itemsByElement.delete(u.element)}),Ee(m,A()),this.state.groups.set(e,m),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=L(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=Ge();this.setHash(De(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?Re(this.state,Ae(e)):null}setPosByCurrentIndex(){let e=C(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=L(this.state);e&&(Be(e,A(),X(),this.state.options.headerHeight,this.state.options.footerHeight),this.syncFillScale())}resetTranslateCurrent(){Ee(L(this.state),A())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}currentLiElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.li;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;e.style.transition=this.state.options.showAnimation===!1?"none":"",this.state.viewer.isOpen&&!e.open?(e.style.removeProperty("display"),e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&(e.close(),e.style.display="none")}commit(){this.view.render(this.state),this.view.updatePhotoTransform(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=L(this.state);this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),ge(this.state)}syncFillScale(){if(this.state.options.resizeStyle!=="fill"||!this.isSmartPhoneFlag)return;let e=C(this.state);e&&(this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=k(e,A(),X(),this.isSmartPhoneFlag))}supportsViewTransition(){return this.state.options.useViewTransitionApi&&typeof document.startViewTransition=="function"&&!Ie()}openPhotoWithViewTransition(e){var n,m;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(n=e==null?void 0:e.querySelector("img"))!=null?n:null;o&&(o.style.viewTransitionName=i);let r=()=>{this.isViewTransitionActive=!1,o&&(o.style.viewTransitionName="");let p=this.currentImgElement();if(p&&(p.style.viewTransitionName=""),!this.state.viewer.isOpen){this.pendingViewTransitionResync=!1;return}if(this.pendingViewTransitionResync&&L(this.state)){this.pendingViewTransitionResync=!1,this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit();return}this.pendingViewTransitionResync=!1,this.view.resetViewTransitionLayout()},s=(m=document.startViewTransition)==null?void 0:m.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i,this.view.applyViewTransitionLayout(this.state)});s&&(this.isViewTransitionActive=!0,s.ready.catch(()=>{r()}),s.finished.then(r,r))}addAppearEffect(e,i){var T;let o=(T=e==null?void 0:e.querySelector("img"))!=null?T:null;if(!o){this.state.viewer.appear=!0;return}let r=He(o),s=o.offsetWidth,n=o.offsetHeight,m=A(),p=X(),u=p-this.state.options.headerHeight-this.state.options.footerHeight,f=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?f=p/n:f=m/s:(s>=n?i.height<u?f=i.width/s:f=u/n:i.height<u?f=i.height/n:f=u/n,s*f>m&&(f=m/s));let P=(f-1)/2*s+(m-s*f)/2,b=(f-1)/2*n+(p-n*f)/2,H=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:H||i.src||"",afterX:P,afterY:b,scale:f}}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=A(),i=X();requestAnimationFrame(()=>{if(this.state.viewer.isOpen&&!(A()===e&&X()===i)){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}})}openPhoto(e,i){let o=this.rootSelector?this.resyncGroupFromDom(e.groupId):!1;this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,(this.syncedGroupId!==e.groupId||o)&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{if(this.state.options.showAnimation===!1){i();return}let o=this.view.refs.dialog,r=C(this.state),s=r?this.currentLiElement():null,n=X(),m=this.currentImgElement(),p=null;if(m){let f=getComputedStyle(m).transform;f&&f!=="none"&&(m.style.transform=f,p=m.style.transform)}if(s&&r){let f=e==="top"?-n:n;s.style.transform=`translate(${r.translateX}px,${r.translateY+f}px)`}let u=f=>{this.finishHideEffect===u&&(f&&f.target!==o||(this.finishHideEffect=null,o.removeEventListener("transitionend",u,!0),m&&p&&m.style.transform===p&&(m.style.transform=""),i()))};this.finishHideEffect=u,o.addEventListener("transitionend",u,!0),this.scheduleTimeout(u,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(r=e.src)!=null?r:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=L(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.updateViewportHeight(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=C(this.state);this.state.viewer.onMove=!1,ge(this.state),this.state.viewer.isOpen&&this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(r=>r!==o),e()},i);return this.timeouts.push(o),o}applyAutoIconContrast(){let e=this.view.refs.dialog,i=getComputedStyle(e);if(i.getPropertyValue("--smartphoto-icon-color").trim())return;let o=i.getPropertyValue("--smartphoto-backdrop-color").trim();o&&e.style.setProperty("--smartphoto-icon-color",Me(o))}fireEvent(e){Ce(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:e=>{let i=this.currentImgElement();!!i&&e instanceof Node&&i.contains(e)&&this.canZoomCurrentPhoto()?this.zoomPhoto():this.hidePhoto()},onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},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 nt=q;return Ke(st);})();
|
|
6
|
+
"use strict";var SmartPhoto=(()=>{var me=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var _e=Object.prototype.hasOwnProperty;var qe=(t,e)=>{for(var i in e)me(t,i,{get:e[i],enumerable:!0})},je=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ue(e))!_e.call(t,r)&&r!==i&&me(t,r,{get:()=>e[r],enumerable:!(o=ke(e,r))||o.enumerable});return t};var Ke=t=>je(me({},"__esModule",{value:!0}),t);var st={};qe(st,{default:()=>nt});var Z=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},Ie=()=>typeof window.webkitConvertPointFromNodeToPage=="function";function Le(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]=Le((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var Te=Le,Ce=(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)},Ae=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},J=()=>document.documentElement.clientWidth,ee=()=>{let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight},He=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var xe=t=>{let e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/);return e?[Number(e[1]),Number(e[2]),Number(e[3])]:null},Qe=.179,Ze=([t,e,i])=>{let[o,r,s]=[t,e,i].map(n=>{let m=n/255;return m<=.03928?m/12.92:((m+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*s},Me=t=>{let e=t.trim(),i=xe(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=xe(getComputedStyle(o).color),document.body.removeChild(o)}return i&&Ze(i)>Qe?"#000":"#fff"};var Je={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,useViewTransitionApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:300};function Ve(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Ve(i)}),Object.freeze(t)}function ze(t){return{options:Ve(Te({},Je,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function _(t){return t.getAttribute("data-group")||"nogroup"}function fe(t){return t.group||"nogroup"}function ve(t,e,i,o){let r=_(t),s=t.getAttribute("href"),n=t.querySelector("img"),m=s;n&&(n.getAttribute(e.lazyAttribute)?m=n.getAttribute(e.lazyAttribute):n.currentSrc?m=n.currentSrc:m=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 u=t.getAttribute("data-id");return{src:s,thumb:m,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:u||i,loaded:!1,processed:!1,element:t}}function Oe(t,e,i){var u,f,P,b,H;let o=fe(t),r=t.src,s=(u=t.thumb)!=null?u:r,n=(f=t.caption)!=null?f:null,m=(b=(P=t.alt)!=null?P:n)!=null?b:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:m,groupId:o,translateX:i*e,translateY:0,index:e,width:p?t.width:50,height:p?t.height:50,scale:1,x:0,y:0,id:(H=t.id)!=null?H:e,loaded:p,processed:!1,element:null}}function we(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 L(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function C(t){var i;let e=L(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function ge(t){let e=L(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 ye(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function te(t,e){let i=10**e;return Math.round(t*i)/i}function k(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Ne(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,m,p,u;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(u=(o-s)/2,m=-1*u):(u=(s-o)/2,m=-1*u),{minX:te(n,6)/t.scale,minY:te(m,6)/t.scale,maxX:te(p,6)/t.scale,maxY:te(u,6)/t.scale}}function Be(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 De(t){let e=C(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function Re(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(r=>{e.group===r.groupId&&e.photo===r.id&&(i=r)})}),i}function Ee(t,e){let i=10**e;return Math.round(t*i)/i}function U(t){return{x:t.pageX,y:t.pageY}}function Xe(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var et=10;function tt(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ye(){return{width:J(),height:ee()}}function Fe({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,m=null,p=null,u=null,f=0,P=null,b=!1,H=null,T=null,z=0,Y=0,V=!1,R=0,x=null,O=0,c=0;function j(){return Z()}function $(a){let{width:h,height:E}=Ye();return Ne(a,t.viewer,h,E)}function K(a){let{width:h,height:E}=Ye();return k(a,h,E,j())}function oe(a,h){let E=C(t),y=$(E);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=y.minX:a===-1&&(t.viewer.photoPosX=y.maxX),h===1?t.viewer.photoPosY=y.minY:h===-1&&(t.viewer.photoPosY=y.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let F=setInterval(()=>{if(V||s||b||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=O,t.viewer.photoPosY+=c;let a=C(t);if(!a)return;let h=$(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,O*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,O*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,c*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,c*=-.2);let E=tt(O,c),y=E.force-t.options.registance;Math.abs(y)<.5||(O=Math.cos(E.theta)*y,c=Math.sin(E.theta)*y,e.onPhotoDragMove())},t.options.forceInterval);function W(a,h){(a>5||a<-5)&&(O+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(c+=h*.05)}function re(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||V||s||b||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",re,{signal:i});function ne(){V=!0,s=!1,b=!1;let a=Array.from(o.values());R=Xe(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function se(a){let h=U(a);s=!0,n=!0,m=h,p=h,f=Date.now(),P=a.target}function ae(a){b=!0;let h=U(a);T=h,H=h}function le(a){var h,E;try{(E=(h=a.currentTarget).setPointerCapture)==null||E.call(h,a.pointerId)}catch(y){}if(o.set(a.pointerId,U(a)),o.size>1){ne();return}if(t.viewer.scale){ae(a);return}se(a)}function he(){x===null&&(x=requestAnimationFrame(()=>{x=null,e.onGestureMove()}))}function ue(){x!==null&&(cancelAnimationFrame(x),x=null,e.onGestureMove())}function ce(){let a=Array.from(o.values()),h=Xe(a[0],a[1]),E=(h-R)/100,y=t.viewer.scaleSize,I=t.viewer.photoPosX,M=t.viewer.photoPosY;t.viewer.scaleSize+=Ee(E,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<y&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-y)*I,t.viewer.photoPosY=(1+t.viewer.scaleSize-y)*M);let D=C(t);if(D){let de=K(D);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>de}R=h,he()}function d(a){let h=U(a),E=h.x-p.x,y=h.y-m.y;n&&(e.onSwipeStart(),n=!1,u=Math.abs(E)>Math.abs(y)?"horizontal":"vertical"),u==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=y,p=h,e.onSwipeMove()}function l(a){let h=U(a),E=h.x-T.x,y=h.y-T.y,I=Ee(t.viewer.scaleSize*E,6),M=Ee(t.viewer.scaleSize*y,6);t.viewer.photoPosX+=I,z=I,t.viewer.photoPosY+=M,Y=M,T=h,e.onPhotoDragMove()}function g(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,U(a)),V){ce();return}if(b){l(a);return}d(a)}}function v(){V=!1,ue();let a=C(t);if(!a)return;let h=K(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 w(){var Pe;s=!1;let a=m,h=p,E=Date.now(),y=r-E,I=h.x-a.x,M=h.y-a.y,D=I===0&&M===0;if(!j()&&D){e.onTap(P);return}if(Math.abs(y)<=500&&D){e.onTap(P);return}r=E;let de=(Pe=L(t))!=null?Pe:[];if(u==="horizontal"){let G="stay",$e=Math.max(E-f,1),Se=Math.abs(I)>=et&&Math.abs(I)/$e>=t.options.swipeVelocity;(I>=t.options.swipeOffset||Se&&I>0)&&t.viewer.currentIndex!==0?G="prev":(I<=-t.options.swipeOffset||Se&&I<0)&&t.viewer.currentIndex!==de.length-1&&(G="next"),e.onSwipeEnd(G)}else{let G="stay";t.options.swipeBottomToClose&&M>=t.options.swipeOffset?G="close-bottom":t.options.swipeTopToClose&&M<=-t.options.swipeOffset&&(G="close-top"),e.onSwipeEnd(G)}}function S(){b=!1;let a=T,h=H;if(a.x===h.x&&a.y===h.y){e.onPhotoDragEnd("zoom-out");return}let E=C(t);if(!E){e.onPhotoDragEnd(null);return}let y=$(E),I=t.options.swipeOffset*t.viewer.scaleSize,M=0,D=0;if(t.viewer.photoPosX>y.maxX?M=-1:t.viewer.photoPosX<y.minX&&(M=1),t.viewer.photoPosY>y.maxY?D=-1:t.viewer.photoPosY<y.minY&&(D=1),t.viewer.photoPosX-y.maxX>I&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(y.minX-t.viewer.photoPosX>I&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}M===0&&D===0?(O=z/5,c=Y/5):oe(M,D),e.onPhotoDragEnd(null)}function N(a){if(o.delete(a.pointerId),V){o.size<2&&v();return}if(b){S();return}s&&w()}function Q(...a){for(let h of a)h.addEventListener("pointerdown",le,{signal:i}),h.addEventListener("pointermove",g,{signal:i}),h.addEventListener("pointerup",N,{signal:i}),h.addEventListener("pointercancel",N,{signal:i})}function B(){clearInterval(F),x!==null&&(cancelAnimationFrame(x),x=null)}return{attach:Q,detach:B}}function ie(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function be(){let t=document.createElement("button");return t.type="button",t}function it(t){return t.replace(/"/g,'\\"')}function We({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let m=document.createElement("dialog");m.className=r.smartPhoto,m.setAttribute("aria-labelledby",`smartphoto-${t}-title`),m.style.display="none",m.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let u=document.createElement("div");u.className=r.smartPhotoInner;let f=document.createElement("div");f.className=r.smartPhotoHeader;let P=document.createElement("span");P.className=r.smartPhotoCount;let b=document.createElement("h1");b.id=`smartphoto-${t}-title`,b.className=r.smartPhotoCaption,b.setAttribute("tabindex","-1");let H=document.createElement("button");H.className=r.smartPhotoDismiss,H.appendChild(ie(s.closeDialog)),H.addEventListener("click",()=>i.onDismiss(),{signal:o}),f.append(P,b,H);let T=document.createElement("div");T.className=r.smartPhotoContent,T.addEventListener("click",d=>{d.target===T&&i.onBackdropClick()},{signal:o});let z=document.createElement("ul");z.className=r.smartPhotoList,z.setAttribute("role","region"),z.setAttribute("aria-roledescription","carousel"),z.setAttribute("aria-label",s.carouselLabel),z.setAttribute("aria-live","polite"),z.setAttribute("aria-atomic","false"),u.append(f,T,z);let Y=null,V=null,R=null;if(e.arrows){Y=document.createElement("ul"),Y.className=r.smartPhotoArrows,V=document.createElement("li"),V.className=r.smartPhotoArrowLeft;let d=be();d.appendChild(ie(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(d),R=document.createElement("li"),R.className=r.smartPhotoArrowRight;let l=be();l.appendChild(ie(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),R.appendChild(l),Y.append(V,R),u.appendChild(Y)}let x=null,O=null;e.nav&&(x=document.createElement("nav"),x.className=r.smartPhotoNav,x.setAttribute("aria-label","Choose slide to display"),O=document.createElement("ul"),x.appendChild(O),u.appendChild(x)),p.appendChild(u),m.appendChild(p),n.appendChild(m);let c={dialog:m,count:P,caption:b,dismiss:H,content:T,list:z,arrows:Y,arrowLeft:V,arrowRight:R,nav:x,navList:O,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 $(d){var v,w;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let g=document.createElement("img");return g.className=r.smartPhotoImg,g.src=(v=d.src)!=null?v:"",g.alt=(w=d.alt)!=null?w:"",g.addEventListener("dragstart",S=>S.preventDefault(),{signal:o}),l.appendChild(g),{imgWrap:l,img:g}}function K(d,l){var g;c.list.replaceChildren(),(g=c.navList)==null||g.replaceChildren(),c.slides=new Map,d.forEach(v=>{var N,Q;let w=document.createElement("li");w.setAttribute("role","group"),w.setAttribute("aria-roledescription","slide"),w.setAttribute("aria-label",`${v.index+1} of ${d.length}`);let S={li:w,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(v.processed){let{imgWrap:B,img:a}=$(v);w.appendChild(B),S.imgWrap=B,S.img=a}else{let B=j();w.appendChild(B),S.loaderWrap=B}if(c.list.appendChild(w),c.slides.set(v,S),c.navList){let B=document.createElement("li"),a=be();a.style.backgroundImage=`url("${it((N=v.thumb)!=null?N:"")}")`;let h=v.index;a.addEventListener("click",()=>i.onNavigate(h),{signal:o}),a.appendChild(ie(`go to ${(Q=v.caption)!=null?Q:""}`)),B.appendChild(a),c.navList.appendChild(B),S.navLink=a}}),W(l)}function oe(d,l){var w;if(l.imgWrap||!d.processed)return l;let{imgWrap:g,img:v}=$(d);return(w=l.loaderWrap)==null||w.replaceWith(g),l.loaderWrap=null,l.imgWrap=g,l.img=v,l}function F(d){d&&document.activeElement&&d.contains(document.activeElement)&&c.caption.focus()}function W(d){let{viewer:l}=d;c.count.textContent=`${l.currentIndex+1}/${l.total}`,c.slides.forEach((g,v)=>{var N;let w=oe(v,g),S=v.index===l.currentIndex;w.li.style.transform=`translate(${v.translateX}px,${v.translateY}px)`,w.li.classList.toggle("current",S),S?w.li.removeAttribute("aria-hidden"):w.li.setAttribute("aria-hidden","true"),S&&(c.caption.textContent=(N=v.caption)!=null?N:""),w.imgWrap&&w.img&&(w.imgWrap.style.transform=`translate(${v.x}px,${v.y}px) scale(${v.scale})`,w.img.style.width=`${v.width}px`,S||(w.img.style.transform="translate(0px,0px) scale(1)"),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"))}),c.arrowLeft&&(l.showPrevArrow?c.arrowLeft.removeAttribute("aria-hidden"):(F(c.arrowLeft),c.arrowLeft.setAttribute("aria-hidden","true"))),c.arrowRight&&(l.showNextArrow?c.arrowRight.removeAttribute("aria-hidden"):(F(c.arrowRight),c.arrowRight.setAttribute("aria-hidden","true"))),c.arrows&&(l.hideUi&&F(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.nav&&(l.hideUi&&F(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function re(d){for(let[l,g]of c.slides)if(l.index===d.viewer.currentIndex)return g;return null}function ne(d){let{viewer:l}=d,g=re(d),v=g==null?void 0:g.img;v&&(v.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,v.classList.toggle(r.smartPhotoImgOnMove,l.scale),v.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),c.nav&&(l.hideUi&&F(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.arrows&&(l.hideUi&&F(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function se(d){let{viewer:l}=d;c.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,c.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function ae(d){for(let[l,g]of c.slides){if(l.index!==d.viewer.currentIndex)continue;let{img:v,imgWrap:w}=g;if(!v||!w||!l.width||!l.scale||l.scale>=1)return;let S=v.getBoundingClientRect();v.style.width=`${l.width*l.scale}px`,w.style.transform=`translate(${l.x}px,${l.y}px) scale(1)`;let N=v.getBoundingClientRect();w.style.transform=`translate(${l.x+S.left-N.left}px,${l.y+S.top-N.top}px) scale(1)`;return}}function le(){for(let[d,l]of c.slides){let{img:g,imgWrap:v}=l;g&&v&&(v.style.transform=`translate(${d.x}px,${d.y}px) scale(${d.scale})`,g.style.width=`${d.width}px`)}}function he(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),c.imgClone=l}function ue(){var d;(d=c.imgClone)==null||d.remove(),c.imgClone=null}function ce(){n.remove()}return{root:n,refs:c,render:W,syncSlides:K,updatePhotoTransform:ne,applyViewTransitionLayout:ae,resetViewTransitionLayout:le,updateListTransform:se,showAppearEffect:he,removeAppearEffect:ue,destroy:ce}}var A=J,X=ee;function ot(t){return t.length>0&&t[0]instanceof Element}function rt(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function Ge(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var q=class{constructor(e,i){this.id=rt();this.abortController=new AbortController;this.isSmartPhoneFlag=Z();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.isViewTransitionActive=!1;this.pendingViewTransitionResync=!1;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.rootSelector=null;this.itemsByElement=new Map;this.handleDocumentClick=e=>{if(!(e.target instanceof Element))return;let i=e;if(i.__smartphotoClaimed)return;let o=this.findRegisteredAncestor(e.target);if(!o&&this.rootSelector&&(o=e.target.closest(this.rootSelector)),!o)return;if(e.preventDefault(),i.__smartphotoClaimed=!0,!this.itemsByElement.has(o)&&this.rootSelector){let s=_(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let r=this.itemsByElement.get(o);r&&this.openPhoto(r,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${X()}px`)};this.handleVisualViewportResize=()=>{if(this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!L(this.state))){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}};this.handleResize=()=>{if(!(!this.state.viewer.isOpen||!L(this.state))){if(this.updateViewportHeight(),this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!this.state.viewer.isOpen||!L(this.state))return;if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=A(),i=500,o=r=>{this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(e!==A()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25))},25)};o(0)};this.rootSelector=typeof e=="string"?e:null,this.state=ze(i!=null?i:{}),this.view=We({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Fe({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),document.addEventListener("click",this.handleDocumentClick,{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&this.openPhoto(o,o.element),this.updateViewportHeight(),this.applyAutoIconContrast(),window.visualViewport?window.visualViewport.addEventListener("resize",this.handleVisualViewportResize,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,r=s=>i.call(o,s);o.addEventListener(e,r,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.itemsByElement.clear(),this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){var s,n;let i=Number.parseInt(String(e),10),o=Number.isNaN(i)?0:i,r=(n=(s=L(this.state))==null?void 0:s.length)!=null?n:0;o<0||o>=r||(this.state.viewer.currentIndex=o,this.slideList())}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=Ge();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=C(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=k(e,A(),X(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin"))},this.state.options.animationSpeed)))}canZoomCurrentPhoto(){let e=C(this.state);return!!e&&k(e,A(),X(),this.isSmartPhoneFlag)>1}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,u,f;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(P=>P.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,m=(f=(u=i.trigger)!=null?u:s.element)!=null?f:n;this.openPhoto(s,m)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof HTMLElement?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!ot(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=_(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=ve(e,this.state.options,o,A());return we(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=fe(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Oe(e,o,A());return we(this.state,r),this.loadAllFired.delete(i),r}findRegisteredAncestor(e){let i=e;for(;i;){if(this.itemsByElement.has(i))return i;i=i.parentElement}return null}resyncGroupFromDom(e){var p;if(!this.rootSelector)return!1;let i=Array.from(document.querySelectorAll(this.rootSelector)).filter(u=>_(u)===e),o=new Set(i),r=(p=this.state.groups.get(e))!=null?p:[],s=new Map;r.forEach(u=>{u.element&&s.set(u.element,u)});let n=i.length!==r.length,m=i.map((u,f)=>{let P=s.get(u);if(P)return P.index!==f&&(n=!0,P.index=f),P;n=!0;let b=ve(u,this.state.options,f,A());return this.itemsByElement.set(u,b),b});return r.forEach(u=>{u.element&&!o.has(u.element)&&this.itemsByElement.delete(u.element)}),ye(m,A()),this.state.groups.set(e,m),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=L(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=Ge();this.setHash(De(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?Re(this.state,Ae(e)):null}setPosByCurrentIndex(){let e=C(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=L(this.state);e&&(Be(e,A(),X(),this.state.options.headerHeight,this.state.options.footerHeight),this.syncFillScale())}resetTranslateCurrent(){ye(L(this.state),A())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}currentLiElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.li;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;e.style.transition=this.state.options.showAnimation===!1?"none":"",this.state.viewer.isOpen&&!e.open?(e.style.removeProperty("display"),e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&(e.close(),e.style.display="none")}commit(){this.view.render(this.state),this.view.updatePhotoTransform(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=L(this.state);this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),ge(this.state)}syncFillScale(){if(this.state.options.resizeStyle!=="fill"||!this.isSmartPhoneFlag)return;let e=C(this.state);e&&(this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=k(e,A(),X(),this.isSmartPhoneFlag))}supportsViewTransition(){return this.state.options.useViewTransitionApi&&typeof document.startViewTransition=="function"&&!Ie()}openPhotoWithViewTransition(e){var n,m;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(n=e==null?void 0:e.querySelector("img"))!=null?n:null;o&&(o.style.viewTransitionName=i);let r=()=>{this.isViewTransitionActive=!1,o&&(o.style.viewTransitionName="");let p=this.currentImgElement();if(p&&(p.style.viewTransitionName=""),!this.state.viewer.isOpen){this.pendingViewTransitionResync=!1;return}if(this.pendingViewTransitionResync&&L(this.state)){this.pendingViewTransitionResync=!1,this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit();return}this.pendingViewTransitionResync=!1,this.view.resetViewTransitionLayout()},s=(m=document.startViewTransition)==null?void 0:m.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i,this.view.applyViewTransitionLayout(this.state)});s&&(this.isViewTransitionActive=!0,s.ready.catch(()=>{r()}),s.finished.then(r,r))}addAppearEffect(e,i){var T;let o=(T=e==null?void 0:e.querySelector("img"))!=null?T:null;if(!o){this.state.viewer.appear=!0;return}let r=He(o),s=o.offsetWidth,n=o.offsetHeight,m=A(),p=X(),u=p-this.state.options.headerHeight-this.state.options.footerHeight,f=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?f=p/n:f=m/s:(s>=n?i.height<u?f=i.width/s:f=u/n:i.height<u?f=i.height/n:f=u/n,s*f>m&&(f=m/s));let P=(f-1)/2*s+(m-s*f)/2,b=(f-1)/2*n+(p-n*f)/2,H=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:H||i.src||"",afterX:P,afterY:b,scale:f}}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=A(),i=X();requestAnimationFrame(()=>{if(this.state.viewer.isOpen&&!(A()===e&&X()===i)){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}})}openPhoto(e,i){let o=this.rootSelector?this.resyncGroupFromDom(e.groupId):!1;this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,(this.syncedGroupId!==e.groupId||o)&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{if(this.state.options.showAnimation===!1){i();return}let o=this.view.refs.dialog,r=C(this.state),s=r?this.currentLiElement():null,n=X(),m=this.currentImgElement(),p=null;if(m){let f=getComputedStyle(m).transform;f&&f!=="none"&&(m.style.transform=f,p=m.style.transform)}if(s&&r){let f=e==="top"?-n:n;s.style.transform=`translate(${r.translateX}px,${r.translateY+f}px)`}let u=f=>{this.finishHideEffect===u&&(f&&f.target!==o||(this.finishHideEffect=null,o.removeEventListener("transitionend",u,!0),m&&p&&m.style.transform===p&&(m.style.transform=""),i()))};this.finishHideEffect=u,o.addEventListener("transitionend",u,!0),this.scheduleTimeout(u,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(r=e.src)!=null?r:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=L(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.updateViewportHeight(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=C(this.state);this.state.viewer.onMove=!1,ge(this.state),this.state.viewer.isOpen&&this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(r=>r!==o),e()},i);return this.timeouts.push(o),o}applyAutoIconContrast(){let e=this.view.refs.dialog,i=getComputedStyle(e);if(i.getPropertyValue("--smartphoto-icon-color").trim())return;let o=i.getPropertyValue("--smartphoto-backdrop-color").trim();o&&e.style.setProperty("--smartphoto-icon-color",Me(o))}fireEvent(e){Ce(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:e=>{let i=this.currentImgElement();!!i&&e instanceof Node&&i.contains(e)&&this.canZoomCurrentPhoto()?this.zoomPhoto():this.hidePhoto()},onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},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 nt=q;return Ke(st);})();
|
|
7
7
|
SmartPhoto = SmartPhoto.default;
|
package/lib/smartphoto.js
CHANGED
|
@@ -181,7 +181,7 @@ var defaults = {
|
|
|
181
181
|
loadOffset: 2,
|
|
182
182
|
resizeStyle: "fit",
|
|
183
183
|
lazyAttribute: "data-src",
|
|
184
|
-
animationSpeed:
|
|
184
|
+
animationSpeed: 300
|
|
185
185
|
};
|
|
186
186
|
function deepFreeze(obj) {
|
|
187
187
|
Object.keys(obj).forEach((key) => {
|
|
@@ -378,10 +378,10 @@ function makeBound(item, viewer, winWidth, winHeight) {
|
|
|
378
378
|
minY = -1 * maxY;
|
|
379
379
|
}
|
|
380
380
|
return {
|
|
381
|
-
minX: round(minX, 6)
|
|
382
|
-
minY: round(minY, 6)
|
|
383
|
-
maxX: round(maxX, 6)
|
|
384
|
-
maxY: round(maxY, 6)
|
|
381
|
+
minX: round(minX, 6) / item.scale,
|
|
382
|
+
minY: round(minY, 6) / item.scale,
|
|
383
|
+
maxX: round(maxX, 6) / item.scale,
|
|
384
|
+
maxY: round(maxY, 6) / item.scale
|
|
385
385
|
};
|
|
386
386
|
}
|
|
387
387
|
function sizeItems(items, winWidth, winHeight, headerHeight, footerHeight) {
|
|
@@ -758,7 +758,7 @@ function createGestures({ state, callbacks }, { signal }) {
|
|
|
758
758
|
photoSwipable = false;
|
|
759
759
|
const oldPos_ = oldPhotoPos;
|
|
760
760
|
const firstPos_ = firstPhotoPos;
|
|
761
|
-
if (oldPos_.x === firstPos_.x) {
|
|
761
|
+
if (oldPos_.x === firstPos_.x && oldPos_.y === firstPos_.y) {
|
|
762
762
|
callbacks.onPhotoDragEnd("zoom-out");
|
|
763
763
|
return;
|
|
764
764
|
}
|
package/lib/smartphoto.mjs
CHANGED
|
@@ -155,7 +155,7 @@ var defaults = {
|
|
|
155
155
|
loadOffset: 2,
|
|
156
156
|
resizeStyle: "fit",
|
|
157
157
|
lazyAttribute: "data-src",
|
|
158
|
-
animationSpeed:
|
|
158
|
+
animationSpeed: 300
|
|
159
159
|
};
|
|
160
160
|
function deepFreeze(obj) {
|
|
161
161
|
Object.keys(obj).forEach((key) => {
|
|
@@ -352,10 +352,10 @@ function makeBound(item, viewer, winWidth, winHeight) {
|
|
|
352
352
|
minY = -1 * maxY;
|
|
353
353
|
}
|
|
354
354
|
return {
|
|
355
|
-
minX: round(minX, 6)
|
|
356
|
-
minY: round(minY, 6)
|
|
357
|
-
maxX: round(maxX, 6)
|
|
358
|
-
maxY: round(maxY, 6)
|
|
355
|
+
minX: round(minX, 6) / item.scale,
|
|
356
|
+
minY: round(minY, 6) / item.scale,
|
|
357
|
+
maxX: round(maxX, 6) / item.scale,
|
|
358
|
+
maxY: round(maxY, 6) / item.scale
|
|
359
359
|
};
|
|
360
360
|
}
|
|
361
361
|
function sizeItems(items, winWidth, winHeight, headerHeight, footerHeight) {
|
|
@@ -732,7 +732,7 @@ function createGestures({ state, callbacks }, { signal }) {
|
|
|
732
732
|
photoSwipable = false;
|
|
733
733
|
const oldPos_ = oldPhotoPos;
|
|
734
734
|
const firstPos_ = firstPhotoPos;
|
|
735
|
-
if (oldPos_.x === firstPos_.x) {
|
|
735
|
+
if (oldPos_.x === firstPos_.x && oldPos_.y === firstPos_.y) {
|
|
736
736
|
callbacks.onPhotoDragEnd("zoom-out");
|
|
737
737
|
return;
|
|
738
738
|
}
|