@fancyapps/ui
Version:
Robust JavaScript UI Component Library
4 lines • 30.1 kB
JavaScript
!/*! License details at fancyapps.com/license */function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).window=e.window||{})}(this,function(e){"use strict";let t,n=e=>"object"==typeof e&&null!==e&&e.constructor===Object&&"[object Object]"===Object.prototype.toString.call(e),o=function(e="",t="",n=""){return e.split(t).join(n)},i=function(e){if(!(e&&e instanceof Element&&e.offsetParent))return!1;let t=e.scrollHeight>e.clientHeight,n=window.getComputedStyle(e).overflowY,o=-1!==n.indexOf("hidden"),i=-1!==n.indexOf("visible");return t&&!o&&!i},a=function(e,t){return!e||e===document.body||t&&e===t?null:i(e)?e:a(e.parentElement,t)},r=function(e){var t=new DOMParser().parseFromString(e,"text/html").body;if(t.childElementCount>1){for(var n=document.createElement("div");t.firstChild;)n.appendChild(t.firstChild);return n}let o=t.firstChild;if(o&&!(o instanceof HTMLElement)){var n=document.createElement("div");return n.appendChild(o),n}return o},l=function(e=0,t=0,n=0){return Math.max(Math.min(t,n),e)};function s(e){return n(e)||Array.isArray(e)}function c(e,t){let n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every(n=>{let o=e[n],i=t[n];return"function"==typeof o?`${o}`==`${i}`:s(o)&&s(i)?c(o,i):o===i})}let u=1/60*3e3,f=function(e){for(let t of x)t.getState()===d.Running&&t.tick(M?e-M:0);M=e,w=window.requestAnimationFrame(f)},d=((h={})[h.Initializing=0]="Initializing",h[h.Running=1]="Running",h[h.Paused=2]="Paused",h[h.Completed=3]="Completed",h[h.Destroyed=4]="Destroyed",h);var h,g,m,p,v,y=((g=y||{})[g.Spring=0]="Spring",g[g.Ease=1]="Ease",g);let b=((m={})[m.Loop=0]="Loop",m[m.Reverse=1]="Reverse",m),x=new Set,w=null,M=0;function E(){let e=d.Initializing,t=y.Ease,n=0,o=0,i=E.Easings.Linear,a=500,r=0,s=0,h=0,g=0,m=1/0,p=.01,v=.01,M=!1,T={},L=null,S={},R={},k={},A=0,z=0,C=b.Loop,O=E.Easings.Linear,I=new Map;function F(e,...t){for(let n of I.get(e)||[])n(...t)}function P(e){return o=0,e?L=setTimeout(()=>{Z()},e):Z(),Y}function Z(){e=d.Running,F("start",S,R)}function D(){if(e=d.Completed,k={},F("end",S),e===d.Completed)if(n<A){if(n++,C===b.Reverse){let e={...T};T={...R},R=e}P(z)}else n=0;return Y}let Y={getState:function(){return e},easing:function(e){return i=e,t=y.Ease,k={},Y},duration:function(e){return a=e,Y},spring:function(e={}){t=y.Spring;let{velocity:n,mass:o,tension:i,friction:a,restDelta:l,restSpeed:c,maxSpeed:u,clamp:f}={velocity:0,mass:1,tension:170,friction:26,restDelta:.1,restSpeed:.1,maxSpeed:1/0,clamp:!0,...e};return r=n,s=o,h=i,g=a,v=l,p=c,m=u,M=f,k={},Y},isRunning:function(){return e===d.Running},isSpring:function(){return t===y.Spring},from:function(e){return S={...e},Y},to:function(e){return R=e,Y},repeat:function(e,t=0,n=b.Loop,o){return A=e,z=t,C=n,O=o||i,Y},on:function(e,t){return I.set(e,[...I.get(e)||[],t]),Y},off:function(e,t){return I.has(e)&&I.set(e,I.get(e).filter(e=>e!==t)),Y},start:function(t){return e=d.Initializing,c(T={...S},R)||(x.add(this),w||(w=window.requestAnimationFrame(f)),P(t)),Y},pause:function(){return L&&(clearTimeout(L),L=null),e===d.Running&&(e=d.Paused,F("pause",S)),Y},end:D,tick:function(n){n>u&&(n=u),o+=n;let f=0,x=!1;if(e!==d.Running)return Y;if(t===y.Ease){x=1===(f=l(0,o/a,1));let e=C===b.Reverse?O:i;for(let t in S)S[t]=T[t]+(R[t]-T[t])*e(f)}if(t===y.Spring){let e=.001*n,t=0;for(let n in S){let o=R[n],i=S[n];if(!("number"==typeof o&&!isNaN(o))||!("number"==typeof i&&!isNaN(i)))continue;if(Math.abs(o-i)<=v){S[n]=o,k[n]=0;continue}k[n]||("object"==typeof r&&"number"==typeof r[n]?k[n]=r[n]:"number"==typeof r?k[n]=r:k[n]=0);let a=k[n],c=(a=l(-1*Math.abs(m),a,Math.abs(m)))*s*g,u=Math.abs(o-i)*h;a+=((i>o?-1:1)*u-c)/s*e,i+=a*e;let f=S[n]>o?i<o:i>o,d=Math.abs(a)<p&&Math.abs(o-i)<=v;M&&f&&(d=!0),d?(i=o,a=0):t++,S[n]=i,k[n]=a}x=!t}let w={...R};return F("step",S,T,R,f),x&&e===d.Running&&c(R,w)&&(e=d.Completed,D()),Y},getStartValues:function(){return T},getCurrentValues:function(){return S},getCurrentVelocities:function(){return k},getEndValues:function(){return R},destroy:function(){e=d.Destroyed,L&&(clearTimeout(L),L=null),T=S=R={},x.delete(this)}};return Y}function T(e){let t=[];for(let n of"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?e.touches:e instanceof MouseEvent&&"mouseup"!==e.type?[e]:[])t.push({x:n.clientX,y:n.clientY,ts:Date.now()});return t}function L(e){let t=[];for(let n of"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?e.changedTouches:e instanceof MouseEvent?[e]:[])t.push({x:n.clientX,y:n.clientY,ts:Date.now()});return t}function S(e){let t=e[0],n=e[1]||t;return{x:(t.x+n.x)/2,y:(t.y+n.y)/2,ts:n.ts}}function R(e){let t=e[0],n=e[1]||e[0];return t&&n?-1*Math.sqrt((n.x-t.x)*(n.x-t.x)+(n.y-t.y)*(n.y-t.y)):0}E.destroy=()=>{for(let e of x)e.destroy();w&&(cancelAnimationFrame(w),w=null)},E.Easings={Linear:function(e){return e},EaseIn:function(e){return 0===e?0:Math.pow(2,10*e-10)},EaseOut:function(e){return 1===e?1:1-Math.pow(2,-10*e)},EaseInOut:function(e){return 0===e?0:1===e?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2}};let k=e=>{e.cancelable&&e.preventDefault()},A={passive:!1},z={panThreshold:5,swipeThreshold:3,ignore:["textarea","input","select","[contenteditable]","[data-selectable]","[data-draggable]"]},C=!1,O=!0,I=(e,t)=>{let n,o,i,a={...z,...t},r=[],l=[],s=[],c=!1,u=!1,f=!1,d=0,h=0,g=0,m=0,p=0,v=0,y=0,b=0,x=0,w=[],M=0,E=0,I=new Map;function F(e){let t=R(l),a=R(s),f=Math.abs(y)>Math.abs(b)?y:b,d={srcEvent:i,isPanRecognized:c,isSwipeRecognized:u,firstTouch:r,previousTouch:s,currentTouch:l,deltaX:g,deltaY:m,offsetX:p,offsetY:v,velocityX:y,velocityY:b,velocity:f,angle:x,axis:o,scale:t&&a?t/a:0,center:n};for(let t of I.get(e)||[])t(d)}function P(e){let t=Date.now();w=w.filter(e=>!e.ts||e.ts>t-100),e&&w.push(e)}function Z(){if(y=0,b=0,w.length>3){let e=w[0],t=w[w.length-1];if(e&&t){let n=t.x-e.x,o=t.y-e.y,i=e.ts&&t.ts?t.ts-e.ts:0;i>0&&(y=Math.abs(n)>3?n/(i/30):0,b=Math.abs(o)>3?o/(i/30):0)}}}function D(e){if(e instanceof MouseEvent){if(C)return}else C=!0;let t=e.composedPath()[0],o=a.ignore.join(",");if(t.matches(o)||t.closest(o)||"undefined"!=typeof MouseEvent&&e instanceof MouseEvent&&(!e.buttons||0!==e.button))return;e instanceof MouseEvent&&k(e);let g=Date.now(),m=g-(d||g);f=m>0&&m<=250,d=g,clearTimeout(M),i=e,e instanceof MouseEvent&&(window.addEventListener("mousemove",Y),window.addEventListener("mouseup",X)),window.addEventListener("blur",_),r=[...l=T(e)],s=[],h=l.length,n=S(l),1===h&&(c=!1,u=!1),h&&P(S(l)),F("start")}function Y(e){if(!r.length||e.defaultPrevented)return;i=e,s=[...l],h=(l=T(e)).length;let t=n=S(l),u=S(s);if(g=t.x-u.x,m=t.y-u.y,P(t),Z(),F("move"),l.length>1&&Math.abs(R(l)-R(s))>=.1&&F("pinch"),!c&&r.length){let e=S(r);p=t.x-e.x,v=t.y-e.y,(c=Math.abs(p)>a.panThreshold||Math.abs(v)>a.panThreshold)&&(O=!1,clearTimeout(E),E=0,o=(x=Math.abs(180*Math.atan2(v,p)/Math.PI))>45&&x<135?"y":"x",r=[...l],s=[...l],window.getSelection()?.removeAllRanges(),F("panstart"))}c&&(g||m)&&F("pan")}function X(e){if(i=e,!r.length)return;let t=T(e),o=L(e);if(h=t.length,n=S(o),o.length&&P(S(o)),Z(),s=[...l],l=[...t],r=[...t],t.length>0)F("end"),c=!1,u=!1,w=[];else{let e=a.swipeThreshold;(Math.abs(y)>e||Math.abs(b)>e)&&(u=!0),c&&F("panend"),u&&F("swipe"),c||u||(F("tap"),f?F("doubleTap"):M=setTimeout(function(){F("singleTap")},250)),F("end"),$()}}function _(){clearTimeout(M),$(),c&&F("panend"),F("end")}function $(){c=!1,u=!1,f=!1,h=0,w=[],l=[],s=[],r=[],g=0,m=0,p=0,v=0,y=0,b=0,x=0,o=void 0,window.removeEventListener("mousemove",Y),window.removeEventListener("mouseup",X),window.removeEventListener("blur",_),O||E||(E=setTimeout(()=>{O=!0,E=0},100))}function H(e){let t=e.target;C=!1,t&&!e.defaultPrevented&&(O||(k(e),e.stopPropagation()))}let j={init:function(){if(e)return e.addEventListener("click",H,A),e.addEventListener("mousedown",D,A),e.addEventListener("touchstart",D,A),e.addEventListener("touchmove",Y,A),e.addEventListener("touchend",X),e.addEventListener("touchcancel",X),j},on:function(e,t){return I.set(e,[...I.get(e)||[],t]),j},off:function(e,t){return I.has(e)&&I.set(e,I.get(e).filter(e=>e!==t)),j},isPointerDown:()=>h>0,destroy:function(){clearTimeout(M),clearTimeout(E),E=0,e&&(e.removeEventListener("click",H,A),e.removeEventListener("mousedown",D,A),e.removeEventListener("touchstart",D,A),e.removeEventListener("touchmove",Y,A),e.removeEventListener("touchend",X),e.removeEventListener("touchcancel",X)),e=null,$()}};return j};I.isClickAllowed=()=>O;let F={IMAGE_ERROR:"This image couldn't be loaded. <br /> Please try again later.",MOVE_UP:"Move up",MOVE_DOWN:"Move down",MOVE_LEFT:"Move left",MOVE_RIGHT:"Move right",ZOOM_IN:"Zoom in",ZOOM_OUT:"Zoom out",TOGGLE_FULL:"Toggle zoom level",TOGGLE_1TO1:"Toggle zoom level",ITERATE_ZOOM:"Toggle zoom level",ROTATE_CCW:"Rotate counterclockwise",ROTATE_CW:"Rotate clockwise",FLIP_X:"Flip horizontally",FLIP_Y:"Flip vertically",RESET:"Reset"},P=(e,t="")=>{e&&e.classList&&t.split(" ").forEach(t=>{t&&e.classList.add(t)})},Z=(e,t="")=>{e&&e.classList&&t.split(" ").forEach(t=>{t&&e.classList.remove(t)})},D=(e,t="",n)=>{e&&e.classList&&t.split(" ").forEach(t=>{t&&e.classList.toggle(t,n||!1)})},Y=1e4,X=e=>{e.cancelable&&e.preventDefault()},_=(e,t=Y)=>Math.round(((e=parseFloat(e+"")||0)+Number.EPSILON)*t)/t,$=((p={}).Reset="reset",p.Zoom="zoom",p.ZoomIn="zoomIn",p.ZoomOut="zoomOut",p.ZoomTo="zoomTo",p.ToggleCover="toggleCover",p.ToggleFull="toggleFull",p.ToggleMax="toggleMax",p.IterateZoom="iterateZoom",p.Pan="pan",p.Swipe="swipe",p.Move="move",p.MoveLeft="moveLeft",p.MoveRight="moveRight",p.MoveUp="moveUp",p.MoveDown="moveDown",p.RotateCCW="rotateCCW",p.RotateCW="rotateCW",p.FlipX="flipX",p.FlipY="flipY",p),H={x:0,y:0,scale:1,angle:0,flipX:1,flipY:1},j=((v={})[v.Init=0]="Init",v[v.Loading=1]="Loading",v[v.Error=2]="Error",v[v.Ready=3]="Ready",v[v.Destroyed=4]="Destroyed",v),q={bounds:!0,classes:{container:"f-panzoom",wrapper:"f-panzoom__wrapper",content:"f-panzoom__content",viewport:"f-panzoom__viewport"},clickAction:$.ToggleFull,dblClickAction:!1,gestures:{},height:"auto",l10n:F,maxScale:4,minScale:1,mouseMoveFactor:1,panMode:"drag",protected:!1,singleClickAction:!1,spinnerTpl:'<div class="f-spinner"></div>',wheelAction:$.Zoom,width:"auto"},W=0,V=0,N=0,G=(e,n={},o={})=>{let i,s,c,u,f,d,h,g,m=j.Init,p={...q,...n},v={},y={...H},b={...H},x=[];function w(e){let t=p[e];return t&&"function"==typeof t?t(eb):t}function M(){return e&&e.parentElement&&i&&m===j.Ready}let T=new Map;function R(e,...t){let n=[...T.get(e)||[]];for(let o of(p.on&&n.push(p.on[e]),n))o&&o instanceof Function&&o(eb,...t);"*"!==e&&R("*",e,...t)}function k(e){if(!M()||a(e.target))return;let t=Date.now(),n=l(-1,[-e.deltaX||0,-e.deltaY||0,-e.detail||0].reduce(function(e,t){return Math.abs(t)>Math.abs(e)?t:e}),1);R("wheel",e,n);let o=w("wheelAction");if(!o||e.defaultPrevented)return;let i=b.scale,r=i*(n>0?1.5:.5);if(o===$.Zoom){let o=100>Math.abs(e.deltaY)&&100>Math.abs(e.deltaX);if(t-V<(o?200:45))return void X(e);V=t;let a=ee(),s=ei();if(_(r)<_(a)&&_(i)<=_(a)?(N+=Math.abs(n),r=a):_(r)>_(s)&&_(i)>=_(s)?(N+=Math.abs(n),r=s):(N=0,r=l(a,r,s)),N>7)return}switch(X(e),o){case $.Pan:es(o,{srcEvent:e,deltaX:-(2*e.deltaX),deltaY:-(2*e.deltaY)});break;case $.Zoom:es($.ZoomTo,{srcEvent:e,scale:r,center:{x:e.clientX,y:e.clientY}});break;default:es(o,{srcEvent:e})}}function A(n){let o=n.composedPath()[0];if(!I.isClickAllowed()||!(o&&null!==o&&o instanceof Element&&"nodeType"in o)||n.defaultPrevented||!e?.contains(o)||o.hasAttribute("disabled")||o.hasAttribute("aria-disabled"))return;let a=o.closest("[data-panzoom-action]"),r=a?.dataset?.panzoomAction,l=a?.dataset?.panzoomValue||"";if(r){switch(r){case $.ZoomTo:case $.ZoomIn:case $.ZoomOut:es(r,{scale:parseFloat(l||"")||void 0});break;case $.MoveLeft:case $.MoveRight:es(r,{deltaX:parseFloat(l||"")||void 0});break;case $.MoveUp:case $.MoveDown:es(r,{deltaY:parseFloat(l||"")||void 0});break;default:es(r)}return}if(!i?.contains(o))return;let s={srcEvent:n};if(es(w("clickAction"),s),w("dblClickAction")){let e=Date.now(),n=e-(W||e);W=e,n>0&&n<=250?(t&&(clearTimeout(t),t=void 0),es(w("dblClickAction"),s)):t=setTimeout(()=>{es(w("singleClickAction"),s)},250)}}function z(e){if(g=e,!M()||!J()||y.scale<=1||b.scale<=1||(i?.dataset.animationName||"").indexOf("zoom")>-1)return;let t=K(b.scale);if(!t)return;let{x:n,y:o}=t;es($.Pan,{deltaX:n-b.x,deltaY:o-b.y})}function C(){e&&(Z(e,"is-loading"),e.querySelector(".f-spinner")?.remove())}function O(){if(!e||!s)return;if(C(),s instanceof HTMLImageElement&&!(s.complete&&s.naturalWidth)){m=j.Error,i?.classList.add("has-error"),R("error");return}R("loaded");let{width:t,height:n}=U();s instanceof HTMLImageElement&&(s.setAttribute("width",t+""),s.setAttribute("height",n+"")),i&&(Z(i,"has-error"),s instanceof HTMLImageElement&&(i.setAttribute("width",t+""),i.setAttribute("height",n+""),i.style.aspectRatio=`${t/n||""}`)),d=E().on("start",(e,t)=>{b={...H,...t},void 0!==t.angle&&(t.angle=90*Math.round(t.angle/90)),void 0!==t.flipX&&(t.flipX=t.flipX>0?1:-1),void 0!==t.flipY&&(t.flipY=t.flipY>0?1:-1),el(),R("animationStart")}).on("pause",e=>{b={...H,...e}}).on("step",e=>{if(!M())return void d?.end();if(y={...H,...e},J()||!w("bounds")||ep()||b.scale>y.scale||b.scale<et())return void ec();let t=ea(b.scale),n=!1,o=!1,i=!1,a=!1;y.x<t.x[0]&&(n=!0),y.x>t.x[1]&&(o=!0),y.y<t.y[0]&&(a=!0),y.y>t.y[1]&&(i=!0);let r=!1,s=!1,c=!1,u=!1;b.x<t.x[0]&&(r=!0),b.x>t.x[1]&&(s=!0),b.y<t.y[0]&&(u=!0),b.y>t.y[1]&&(c=!0);let f=!1;(o&&s||n&&r)&&(b.x=l(t.x[0],b.x,t.x[1]),f=!0),(i&&c||a&&u)&&(b.y=l(t.y[0],b.y,t.y[1]),f=!0),f&&d&&d.spring({tension:94,friction:17,maxSpeed:555*b.scale,restDelta:.1,restSpeed:.1,velocity:d.getCurrentVelocities()}).from(y).to(b).start(),ec()}).on("end",()=>{er(),d?.isRunning()||(el(),R("animationEnd"))}),function(){let e=w("gestures");e&&u&&s&&(f=I(u,e).on("start",e=>{if(!d)return;let t=e.srcEvent;J()||((y.scale>1||e.currentTouch.length>1)&&(t?.stopPropagation(),d.pause()),1===e.currentTouch.length&&R("touchStart"))}).on("move",e=>{!J()&&(1!==b.scale||e.currentTouch.length>1)&&(e.srcEvent.preventDefault(),e.srcEvent.stopPropagation())}).on("pan",e=>{if(!M()||J())return;let t=e.srcEvent;(1!==b.scale||e.currentTouch.length>1)&&(X(t),es($.Pan,e))}).on("swipe",e=>{!(!M()||J())&&b.scale>1&&es($.Swipe,e)}).on("tap",e=>{R("click",e)}).on("singleTap",e=>{R("singleClick",e)}).on("doubleTap",e=>{R("dblClick",e)}).on("pinch",e=>{J()||(e.scale>et()?es($.ZoomIn,e):e.scale<et()?es($.ZoomOut,e):es($.Pan,e))}).on("end",e=>{J()||(e.currentTouch.length?(e.srcEvent.stopPropagation(),X(e.srcEvent),d?.end()):(el(),er(),R("touchEnd")))}).init())}(),u&&(u.addEventListener("wheel",k,{passive:!1}),x.push(()=>{u?.removeEventListener("wheel",k,{passive:!1})})),e?.addEventListener("click",A),document?.addEventListener("mousemove",z),x.push(()=>{e?.removeEventListener("click",A),document?.removeEventListener("mousemove",z)});let o=F();y={...o},b={...o},m=j.Ready,ec(),el(),R("ready"),requestAnimationFrame(()=>{C(),u&&(u.style.visibility="")})}function F(){let e={...w("startPos")||{}},t=e.scale,n=1;n="string"==typeof t?Q(t):"number"==typeof t?t:et();let o={...H,...e,scale:n},i=J()?K(n):void 0;if(i){let{x:e,y:t}=i;o.x=e,o.y=t}return o}function G(){let e={top:0,left:0,width:0,height:0};if(i){let t=i.getBoundingClientRect();b.angle%180==90?(e.top=t.top+.5*t.height-.5*t.width,e.left=t.left+.5*t.width-.5*t.height,e.width=t.height,e.height=t.width):(e.top=t.top,e.left=t.left,e.width=t.width,e.height=t.height)}return e}function U(){let e=w("width"),t=w("height");if(s&&"auto"===e){let t=s.getAttribute("width");e=t?parseFloat(t+""):void 0!==s.dataset.width?parseFloat(s.dataset.width+""):u instanceof HTMLImageElement?u.naturalWidth:s instanceof HTMLImageElement?s.naturalWidth:s.getBoundingClientRect().width}else e="string"==typeof e?parseFloat(e):e;if(s&&"auto"===t){let e=s.getAttribute("height");t=e?parseFloat(e+""):void 0!==s.dataset.height?parseFloat(s.dataset.height+""):u instanceof HTMLImageElement?u.naturalHeight:s instanceof HTMLImageElement?s.naturalHeight:s.getBoundingClientRect().height}else t="string"==typeof t?parseFloat(t):t;return{width:e,height:t}}function B(){let e=G();return{width:e.width,height:e.height}}function J(){return"mousemove"===w("panMode")&&matchMedia("(hover: hover)").matches}function K(e){let t=g||w("event"),n=i?.getBoundingClientRect();if(!t||!n||e<=1)return{x:0,y:0};let o=(t.clientX||0)-n.left,a=(t.clientY||0)-n.top,{width:r,height:s}=B(),c=ea(e);if(e>1){let t=w("mouseMoveFactor");t>1&&(e*=t)}let u=r*e,f=s*e,d=(u-r)*.5-o/r*100/100*(u-r),h=(f-s)*.5-a/s*100/100*(f-s);return{x:d=l(c.x[0],d,c.x[1]),y:h=l(c.y[0],h,c.y[1])}}function Q(t="base"){if(!e)return 1;let n=e.getBoundingClientRect(),o=G(),{width:i,height:a}=U(),r=e=>{if("number"==typeof e)return e;switch(e){case"min":case"base":return 1;case"cover":return Math.max(n.height/o.height,n.width/o.width)||1;case"full":case"max":{let e=b.angle%180==90?a:i;return e&&o.width?e/o.width:1}}},s=w("minScale"),c=w("maxScale"),u=Math.min(r("full"),r(s)),f="number"==typeof c?r("full")*c:Math.min(r("full"),r(c));switch(t){case"min":return u;case"base":return l(u,1,f);case"cover":return r("cover");case"full":return Math.min(f,r("full"));case"max":return f}}function ee(){return Q("min")}function et(){return Q("base")}function en(){return Q("cover")}function eo(){return Q("full")}function ei(){return Q("max")}function ea(t){let n={x:[0,0],y:[0,0]},o=e?.getBoundingClientRect();if(!o)return n;let i=G(),a=o.width,r=o.height,l=i.width,s=i.height,c=t=void 0===t?b.scale:t,u=t;if(J()&&t>1){let e=w("mouseMoveFactor");e>1&&(l*t>a+.01&&(c*=e),s*t>r+.01&&(u*=e))}return l*=c,s*=u,t>1&&(l>a&&(n.x[0]=(a-l)*.5,n.x[1]=(l-a)*.5),n.x[0]-=(i.left-o.left)*.5,n.x[1]-=(i.left-o.left)*.5,n.x[0]-=(i.left+i.width-o.right)*.5,n.x[1]-=(i.left+i.width-o.right)*.5,s>r&&(n.y[0]=(r-s)*.5,n.y[1]=(s-r)*.5),n.y[0]-=(i.top-o.top)*.5,n.y[1]-=(i.top-o.top)*.5,n.y[0]-=(i.top+i.height-o.bottom)*.5,n.y[1]-=(i.top+i.height-o.bottom)*.5),n}function er(){if(!M()||!w("bounds")||!d)return;let e=ee(),t=ei(),n=l(e,b.scale,t);if(b.scale<e-.01||b.scale>t+.01)return void es($.ZoomTo,{scale:n});if(d.isRunning()||ep())return;let o=ea(n);b.x<o.x[0]||b.x>o.x[1]||b.y<o.y[0]||b.y>o.y[1]?(b.x=l(o.x[0],b.x,o.x[1]),b.y=l(o.y[0],b.y,o.y[1]),d.spring({tension:170,friction:17,restDelta:.001,restSpeed:.001,maxSpeed:1/0,velocity:d.getCurrentVelocities()}),d.from(y).to(b).start()):ec()}function el(){if(!M())return;let t=em(),n=ep(),o=ev(),a=ey(),r=ef(),l=ed();D(i,"is-fullsize",a),D(i,"is-expanded",o),D(i,"is-dragging",n),D(i,"can-drag",t),D(i,"will-zoom-in",r),D(i,"will-zoom-out",l);let s=eh(),c=eg(),u=!M();for(let t of e?.querySelectorAll("[data-panzoom-action]")||[]){let e=t.dataset.panzoomAction,n=!1;if(u)n=!0;else switch(e){case $.ZoomIn:s||(n=!0);break;case $.ZoomOut:c||(n=!0);break;case $.ToggleFull:s||c||(n=!0);let o=t.querySelector("g");o&&(o.style.display=a?"none":"");break;case $.ToggleCover:case $.ToggleMax:s||c||(n=!0)}n?(t.setAttribute("aria-disabled",""),t.setAttribute("tabindex","-1")):(t.removeAttribute("aria-disabled"),t.removeAttribute("tabindex"))}}function es(t,n){if(!e||!s||!d||t===$.Swipe&&Math.abs(d.getCurrentVelocities().scale)>.01)return;let o={...b},i=ea(J()?b.scale:y.scale),a=d.getCurrentVelocities(),r=G();n=n||{};let c=(n.currentTouch?.length||0)>1,u=n.velocityX||0,f=n.velocityY||0,h=n.center;!h&&n.srcEvent&&(h=S(L(n.srcEvent)));let g=n.deltaX||0,m=n.deltaY||0;switch(t){case $.MoveRight:g=n.deltaX||100;break;case $.MoveLeft:g=n.deltaX||-100;break;case $.MoveUp:m=n.deltaY||-100;break;case $.MoveDown:m=n.deltaY||100}let p=[];switch(t){case $.Reset:(b={...H}).scale=et();break;case $.Pan:case $.Move:case $.MoveLeft:case $.MoveRight:case $.MoveUp:case $.MoveDown:if(ep()){let e=1,t=1;b.x<=i.x[0]&&u<=0&&(e=.2*Math.max(.01,1-Math.abs(1/r.width*Math.abs(b.x-i.x[0])))),b.x>=i.x[1]&&u>=0&&(e=.2*Math.max(.01,1-Math.abs(1/r.width*Math.abs(b.x-i.x[1])))),b.y<=i.y[0]&&f<=0&&(t=.2*Math.max(.01,1-Math.abs(1/r.height*Math.abs(b.y-i.y[0])))),b.y>=i.y[1]&&f>=0&&(t=.2*Math.max(.01,1-Math.abs(1/r.height*Math.abs(b.y-i.y[1])))),b.x+=g*e,b.y+=m*t}else b.x=l(i.x[0],b.x+g,i.x[1]),b.y=l(i.y[0],b.y+m,i.y[1]);break;case $.Swipe:let v=(e=0)=>Math.sign(e)*Math.pow(Math.abs(e),1.5);b.x+=l(-1e3,v(u),1e3),b.y+=l(-1e3,v(f),1e3),f&&!u&&(b.x=l(i.x[0],b.x,i.x[1])),!f&&u&&(b.y=l(i.y[0],b.y,i.y[1])),a.x=u,a.y=f;break;case $.ZoomTo:b.scale=n.scale||1;break;case $.ZoomIn:b.scale=b.scale*(n.scale||2),c||(b.scale=Math.min(b.scale,ei()));break;case $.ZoomOut:b.scale=b.scale*(n.scale||.5),c||(b.scale=Math.max(b.scale,ee()));break;case $.ToggleCover:p=[et(),en()];break;case $.ToggleFull:p=[et(),eo()];break;case $.ToggleMax:p=[et(),ei()];break;case $.IterateZoom:p=[et(),eo(),ei()];break;case $.Zoom:let x=eo();b.scale>=x-.05?b.scale=et():b.scale=Math.min(x,b.scale*(n.scale||2));break;case $.RotateCW:b.angle+=90;break;case $.RotateCCW:b.angle-=90;break;case $.FlipX:b.flipX*=-1;break;case $.FlipY:b.flipY*=-1}if(void 0!==y.angle&&Math.abs(y.angle)>=360&&(b.angle-=360*Math.floor(y.angle/360),y.angle-=360*Math.floor(y.angle/360)),p.length){let e=p.findIndex(e=>e>b.scale+1/Y);b.scale=p[e]||p[0]}if(c&&(b.scale=l(ee()*(c?.8:1),b.scale,ei()*(c?1.6:1))),J()){let e=K(b.scale);if(e){let{x:t,y:n}=e;b.x=t,b.y=n}}else if(b.scale!==o.scale){let t=0,n=0;if(h)t=h.x,n=h.y;else{let o=e.getBoundingClientRect();t=o.x+.5*o.width,n=o.y+.5*o.height}let a=t-r.left,s=n-r.top;a-=.5*r.width,s-=.5*r.height;let u=(a-o.x)/o.scale,f=(s-o.y)/o.scale;b.x=a-u*b.scale,b.y=s-f*b.scale,!c&&w("bounds")&&(i=ea(),b.x=l(i.x[0],b.x,i.x[1]),b.y=l(i.y[0],b.y,i.y[1]))}if(t===$.Swipe){let e=500*b.scale;d.spring({tension:94,friction:17,maxSpeed:e,restDelta:.1,restSpeed:.1,velocity:a})}else t===$.Pan||c?d.spring({tension:900,friction:17,restDelta:.01,restSpeed:.01,maxSpeed:1}):d.spring({tension:170,friction:17,restDelta:.001,restSpeed:.001,maxSpeed:1/0,velocity:a});t===$.Reset||0===n.velocity?y={...b}:d.from(y).to(b).start(),R("action",t)}function ec(){if(!s)return;if(i){let{width:e,height:t}=U();i.style.maxWidth=`min(${e}px, 100%)`,i.style.maxHeight=`min(${t}px, 100%)`}let{x:t,y:n,scale:o,angle:a,flipX:r,flipY:l}=y,c=`translate3d(${t}px, ${n}px, 0)`;1!==r||1!==l?c+=` scaleX(${o*r}) scaleY(${o*l})`:1!==o&&(c+=` scale(${o})`),a%360!=0&&(c+=` rotate(${a}deg)`);let f=function(){let{width:t,height:n}=U(),{width:o,height:i}=B();if(!e)return{x:0,y:0,width:0,height:0,scale:0,flipX:0,flipY:0,angle:0,fitWidth:o,fitHeight:i,fullWidth:t,fullHeight:n};let{x:a,y:r,scale:l,angle:s,flipX:c,flipY:u}=y,f=1/eo(),d=t,h=n,g=y.scale*f,m=b.scale*f,p=Math.max(o,i),v=Math.min(o,i);t>n?(d=p,h=v):(d=v,h=p),g=t>n?p*l/t||1:p*l/n||1;let x=d?t*m:0,w=h?n*m:0,M=d&&h?t*g/x:0;return{x:a=a+.5*d-.5*x,y:r=r+.5*h-.5*w,width:x,height:w,scale:M,flipX:c,flipY:u,angle:s,fitWidth:o,fitHeight:i,fullWidth:t,fullHeight:n}}();if(f){let{x:e,y:t,width:n,height:o,scale:i,flipX:r,flipY:l}=f,s=`translate(${_(e)}px, ${_(t)}px)`;1!==r||1!==l?s+=` scaleX(${_(i*r)}) scaleY(${_(i*l)})`:s+=` scale(${_(i)})`,0!==a&&(s+=` rotate(${a}deg)`),u&&(u.style.width=`${_(n)}px`,u.style.height=`${_(o)}px`,u.style.transform=`${s}`)}R("render")}function eu(){let e=b.scale,t=void 0,n=w("clickAction"),o=et();if(n){let i=[];switch(n){case $.ZoomIn:o=e*(t||2);break;case $.ZoomOut:o=e*(t||.5);break;case $.ToggleCover:i=[et(),en()];break;case $.ToggleFull:i=[et(),eo()];break;case $.ToggleMax:i=[et(),ei()];break;case $.IterateZoom:i=[et(),eo(),ei()];break;case $.Zoom:let a=eo();o=e>=a-.05?et():Math.min(a,e*(t||2))}if(i.length){let t=i.findIndex(t=>t>e+1/Y);o=i[t]||et()}}return l(ee(),o,ei())}function ef(){return!!(M()&&eu()>b.scale)}function ed(){return!!(M()&&eu()<b.scale)}function eh(){return!!(M()&&b.scale<ei())}function eg(){return!!(M()&&b.scale>ee())}function em(){return!!(M()&&ev()&&f&&!J())}function ep(){return!!(M()&&f?.isPointerDown()&&!J())}function ev(){return!!(M()&&b.scale>et())}function ey(){return!!(M()&&b.scale>=eo())}let eb={canDrag:em,canZoomIn:eh,canZoomOut:eg,destroy:function(){for(let e of(R("destroy"),Object.values(v)))e?.destroy(eb);for(let e of x)e();return i&&(i.style.aspectRatio="",i.style.maxWidth="",i.style.maxHeight=""),u&&(u.style.width="",u.style.height="",u.style.transform=""),i=void 0,s=void 0,u=void 0,y={...H},b={...H},d?.destroy(),d=void 0,f?.destroy(),f=void 0,m=j.Destroyed,eb},emit:R,execute:es,getBoundaries:ea,getContainer:function(){return e},getContent:function(){return s},getFullDim:U,getGestures:function(){return f},getMousemovePos:K,getOptions:function(){return p},getScale:Q,getStartPosition:F,getState:function(){return m},getTransform:function(e){return!0===e?b:y},getTween:function(){return d},getViewport:function(){return u},getWrapper:function(){return i},init:function(){return m=j.Init,R("init"),function(){for(let[e,t]of Object.entries({...o,...p.plugins||{}}))if(e&&!v[e]&&t instanceof Function){let n=t();n.init(eb),v[e]=n}R("initPlugins")}(),function(){let t={...q.classes,...w("classes")};if(e&&(P(e,t.container),s=e.querySelector("."+t.content))){if(s.setAttribute("draggable","false"),(i=e.querySelector("."+t.wrapper))||(P(i=document.createElement("div"),t.wrapper),s.insertAdjacentElement("beforebegin",i),i.insertAdjacentElement("afterbegin",s)),(u=e.querySelector("."+t.viewport))||(P(u=document.createElement("div"),t.viewport),u.insertAdjacentElement("afterbegin",s),i.insertAdjacentElement("beforeend",u)),(c=s.cloneNode(!0)).removeAttribute("id"),i.insertAdjacentElement("afterbegin",c),s instanceof HTMLPictureElement&&(s=s.querySelector("img")),c instanceof HTMLPictureElement&&(c=c.querySelector("img")),u instanceof HTMLPictureElement&&(u=u.querySelector("img")),u&&(u.style.visibility="hidden",w("protected"))){u.addEventListener("contextmenu",e=>{e.preventDefault()});let e=document.createElement("div");P(e,"f-panzoom__protected"),u.appendChild(e)}R("initLayout")}}(),function(){if(e&&i&&!h){let e=null;(h=new ResizeObserver(()=>{M()&&(e=e||requestAnimationFrame(()=>{M()&&(el(),er(),R("refresh")),e=null}))})).observe(i),x.push(()=>{h?.disconnect(),h=void 0,e&&(cancelAnimationFrame(e),e=null)})}}(),function(){if(!e||!s)return;if(!(s instanceof HTMLImageElement&&c instanceof HTMLImageElement))return O();let t=()=>{s&&s instanceof HTMLImageElement&&s.decode().then(()=>{O()}).catch(()=>{O()})};if(m=j.Loading,e.classList.add("is-loading"),R("loading"),c.src&&c.complete)return t();(function(){if(!e||e?.querySelector(".f-spinner"))return;let t=r(w("spinnerTpl"));t&&(t.classList.add("f-spinner"),e.classList.add("is-loading"),i?.insertAdjacentElement("afterbegin",t))})(),c.addEventListener("load",t,!1),c.addEventListener("error",t,!1),x.push(()=>{c?.removeEventListener("load",t,!1),c?.removeEventListener("error",t,!1)})}(),eb},isDragging:ep,isExpanded:ev,isFullsize:ey,localize:function(e,t=[]){let n=w("l10n")||{};e=String(e).replace(/\{\{(\w+)\}\}/g,(e,t)=>n[t]||e);for(let n=0;n<t.length;n++)e=e.split(t[n][0]).join(t[n][1]);return e.replace(/\{\{(.*?)\}\}/g,(e,t)=>t)},off:function(e,t){for(let n of e instanceof Array?e:[e])T.has(n)&&T.set(n,T.get(n).filter(e=>e!==t));return eb},on:function(e,t){for(let n of e instanceof Array?e:[e])T.set(n,[...T.get(n)||[],t]);return eb},version:"6.0.29",willZoomIn:ef,willZoomOut:ed};return eb};G.l10n={en_EN:F},G.getDefaults=()=>q;let U={tpl:e=>`<img class="f-panzoom__content"
${e.srcset?'data-lazy-srcset="{{srcset}}"':""}
${e.sizes?'data-lazy-sizes="{{sizes}}"':""}
data-lazy-src="{{src}}" alt="{{alt}}" />`};e.Zoomable=()=>{let e;function t(t,o){let i=e?.getOptions().Zoomable,a=(n(i)?{...U,...i}:U)[t];return a&&"function"==typeof a&&o?a(o):a}function i(){e&&(e.on("addSlide",l),e.on("removeSlide",s),e.on("attachSlideEl",c),e.on("click",r),e.on("change",a))}function a(){u()}function r(e,t){let n=t.target;n&&!t.defaultPrevented&&n.dataset.panzoomAction&&f(n.dataset.panzoomAction)}function l(n,i){if(!e)return;let a=i.el;if(!a)return;let r=i.src||i.lazySrc||"",l=i.alt||i.caption||`Image #${i.index}`,s=i.srcset||i.lazySrcset||"",c=i.sizes||i.lazySizes||"";if(r&&"string"==typeof r&&!i.html&&(!i.type||"image"===i.type)){i.type="image",i.thumbSrc=i.thumbSrc||r;let e=t("tpl",i);e=o(e,"{{src}}",r+""),e=o(e,"{{alt}}",l+""),e=o(e,"{{srcset}}",s+""),e=o(e,"{{sizes}}",c+""),a.insertAdjacentHTML("afterbegin",e)}if(!a.querySelector(".f-panzoom__content"))return;let f=G(a,{width:i.width&&"auto"!==i.width?parseFloat(i.width+""):"auto",height:i.height&&"auto"!==i.height?parseFloat(i.height+""):"auto",classes:{container:"f-zoomable"},event:()=>e?.getLastMouseMove(),spinnerTpl:()=>e?.getOption("spinnerTpl")||"",...t("Panzoom")});f.on("*",(t,n,...o)=>{e&&("loading"===n&&(i.state=0),"loaded"===n&&(i.state=1),"error"===n&&(i.state=2,e?.showError(i,"{{IMAGE_ERROR}}")),e.emit(`panzoom:${n}`,i,...o),"ready"===n&&e.emit("contentReady",i),i.index===e?.getPageIndex()&&u())}),i.panzoomRef=f}function s(e,t){t.panzoomRef&&(t.panzoomRef.destroy(),t.panzoomRef=void 0)}function c(e,t){let n=t.panzoomRef;if(n)switch(n.getState()){case j.Init:n.init();break;case j.Ready:n.execute($.ZoomTo,{...n.getStartPosition(),velocity:0})}}function u(){let t=e?.getContainer();if(!t)return;let n=e?.getPage()?.slides[0].panzoomRef,o=n?.canZoomIn()||!1,i=n?.canZoomOut()||!1,a=n?.isFullsize()||!1,r=!n||n?.getState()!==j.Ready;for(let e of t?.querySelectorAll("[data-panzoom-action]")||[]){let t=e.dataset.panzoomAction,n=!1;if(r)n=!0;else switch(t){case $.ZoomIn:o||(n=!0);break;case $.ZoomOut:i||(n=!0);break;case $.ToggleFull:o||i||(n=!0);let l=e.querySelector("g");l&&(l.style.display=a?"none":"");break;case $.ToggleCover:case $.ToggleMax:o||i||(n=!0)}n?(e.setAttribute("aria-disabled",""),e.setAttribute("tabindex","-1")):(e.removeAttribute("aria-disabled"),e.removeAttribute("tabindex"))}}function f(t,...n){e?.getPage().slides[0].panzoomRef?.execute(t,...n)}return{init:function(t){!1!==(e=t).getOptions().Zoomable&&e.on("initPlugins",i)},destroy:function(){if(e)for(let t of(e.off("addSlide",l),e.off("removeSlide",s),e.off("attachSlideEl",c),e.off("click",r),e.off("change",a),e.getSlides()))s(e,t);e=void 0},execute:f}}});