UNPKG

@fancyapps/ui

Version:

Robust JavaScript UI Component Library

5 lines • 31.4 kB
/*! License details at fancyapps.com/license */ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.window=e.window||{}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let t=e=>typeof e==`object`&&!!e&&e.constructor===Object&&Object.prototype.toString.call(e)===`[object Object]`,n=e=>typeof e==`string`,r=function(e=``,t=``,n=``){return e.split(t).join(n)},i=e=>e&&e!==null&&e instanceof Element&&`nodeType`in e,a=function(e){if(!(e&&e instanceof Element&&e.offsetParent))return!1;let t=!1,n=!1;if(e.scrollWidth>e.clientWidth){let n=window.getComputedStyle(e).overflowX,r=n.indexOf(`hidden`)!==-1,i=n.indexOf(`clip`)!==-1,a=n.indexOf(`visible`)!==-1;t=!r&&!i&&!a}if(e.scrollHeight>e.clientHeight){let t=window.getComputedStyle(e).overflowY,r=t.indexOf(`hidden`)!==-1,i=t.indexOf(`clip`)!==-1,a=t.indexOf(`visible`)!==-1;n=!r&&!i&&!a}return t||n},o=function(e,t=void 0){return!e||e===document.body||t&&e===t?null:a(e)?e:o(e.parentElement,t)},s=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 r=t.firstChild;if(r&&!(r instanceof HTMLElement)){var n=document.createElement(`div`);return n.appendChild(r),n}return r},c=function(e=0,t=0,n=0){return Math.max(Math.min(t,n),e)};function l(e){return t(e)||Array.isArray(e)}function u(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>{let r=e[n],i=t[n];return typeof r==`function`?`${r}`==`${i}`:!l(r)||!l(i)?r===i:u(r,i)})}let d=function(e){for(let t of h)t.getState()===f.Running&&t.tick(_?e-_:0);_=e,g=window.requestAnimationFrame(d)};var f;(function(e){e[e.Initializing=0]=`Initializing`,e[e.Running=1]=`Running`,e[e.Paused=2]=`Paused`,e[e.Completed=3]=`Completed`,e[e.Destroyed=4]=`Destroyed`})(f||={});var p;(function(e){e[e.Spring=0]=`Spring`,e[e.Ease=1]=`Ease`})(p||={});var m;(function(e){e[e.Loop=0]=`Loop`,e[e.Reverse=1]=`Reverse`})(m||={});let h=new Set,g=null,_=0;function v(){let e=f.Initializing,t=p.Ease,n=0,r=0,i=v.Easings.Linear,a=500,o=0,s=0,l=0,_=0,y=1/0,b=.01,x=.01,S=!1,C={},w=null,T={},E={},D={},O=0,k=0,A=m.Loop,j=v.Easings.Linear,M=new Map;function N(e,t){M.set(e,[...M.get(e)||[],t])}function P(e,t){M.has(e)&&M.set(e,M.get(e).filter(e=>e!==t))}function F(e,...t){for(let n of M.get(e)||[])n(...t)}function I(e){return r=0,e?w=setTimeout(()=>{L()},e):L(),V}function L(){e=f.Running,F(`start`,T,E)}function R(){return w&&=(clearTimeout(w),null),e===f.Running&&(e=f.Paused,F(`pause`,T)),V}function z(n){n>50&&(n=50),r+=n;let d=0,h=!1;if(e!==f.Running)return V;if(t===p.Ease){d=c(0,r/a,1),h=d===1;let e=A===m.Reverse?j:i;for(let t in T)T[t]=C[t]+(E[t]-C[t])*e(d)}if(t===p.Spring){let e=n*.001,t=0;for(let n in T){let r=E[n],i=T[n];if(typeof r!=`number`||isNaN(r)||typeof i!=`number`||isNaN(i))continue;if(Math.abs(r-i)<=x){T[n]=r,D[n]=0;continue}D[n]||(typeof o==`object`&&typeof o[n]==`number`?D[n]=o[n]:typeof o==`number`?D[n]=o:D[n]=0);let a=D[n];a=c(Math.abs(y)*-1,a,Math.abs(y));let u=a*s*_,d=Math.abs(r-i)*l,f=((i>r?-1:1)*d-u)/s;a+=f*e,i+=a*e;let p=T[n]>r?i<r:i>r,m=Math.abs(a)<b&&Math.abs(r-i)<=x;S&&p&&(m=!0),m?(i=r,a=0):t++,T[n]=i,D[n]=a}h=!t}let g={...E};return F(`step`,T,C,E,d),h&&e===f.Running&&u(E,g)&&(e=f.Completed,B()),V}function B(){if(e=f.Completed,D={},F(`end`,T),e===f.Completed){if(n<O){if(n++,A===m.Reverse){let e={...C};C={...E},E=e}I(k)}else n=0}return V}let V={getState:function(){return e},easing:function(e){return i=e,t=p.Ease,D={},V},duration:function(e){return a=e,V},spring:function(e={}){t=p.Spring;let{velocity:n,mass:r,tension:i,friction:a,restDelta:c,restSpeed:u,maxSpeed:d,clamp:f}={velocity:0,mass:1,tension:170,friction:26,restDelta:.1,restSpeed:.1,maxSpeed:1/0,clamp:!0,...e};return o=n,s=r,l=i,_=a,x=c,b=u,y=d,S=f,D={},V},isRunning:function(){return e===f.Running},isSpring:function(){return t===p.Spring},from:function(e){return T={...e},V},to:function(e){return E=e,V},repeat:function(e,t=0,n=m.Loop,r){return O=e,k=t,A=n,j=r||i,V},on:function(e,t){return N(e,t),V},off:function(e,t){return P(e,t),V},start:function(t){return u(T,E)||(e=f.Initializing,C={...T},h.add(this),g||=window.requestAnimationFrame(d),I(t)),V},pause:R,end:B,tick:z,getStartValues:function(){return C},getCurrentValues:function(){return T},getCurrentVelocities:function(){return D},getEndValues:function(){return E},destroy:function(){e=f.Destroyed,w&&=(clearTimeout(w),null),C=T=E={},h.delete(this)}};return V}v.destroy=()=>{for(let e of h)e.destroy();g&&=(cancelAnimationFrame(g),null)},v.Easings={Linear:function(e){return e},EaseIn:function(e){return e===0?0:2**(10*e-10)},EaseOut:function(e){return e===1?1:1-2**(-10*e)},EaseInOut:function(e){return e===0?0:e===1?1:e<.5?2**(20*e-10)/2:(2-2**(-20*e+10))/2}};function y(e){return typeof TouchEvent<`u`&&e instanceof TouchEvent}function b(e,t){let n=[],r=y(e)?e[t]:e instanceof MouseEvent&&(t===`changedTouches`||e.type!==`mouseup`)?[e]:[];for(let e of r)n.push({x:e.clientX,y:e.clientY,ts:Date.now()});return n}function x(e){return b(e,`touches`)}function S(e){return b(e,`targetTouches`)}function C(e){return b(e,`changedTouches`)}function w(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 T(e){let t=e[0],n=e[1]||e[0];return t&&n?Math.sqrt((n.x-t.x)*(n.x-t.x)+(n.y-t.y)*(n.y-t.y))*-1:0}let E=e=>{e.cancelable&&e.preventDefault()},D={passive:!1},O={panThreshold:5,swipeThreshold:3,ignore:[`textarea`,`input`,`select`,`[contenteditable]`,`[data-selectable]`,`[data-draggable]`]},k=!1,A=!0,j=(e,t)=>{let n={...O,...t},r=!0,i,a=[],o=[],s=[],c=!1,l=!1,u=!1,d=!1,f=0,p=0,m,h=0,g=0,_=0,v=0,y=0,b=0,j=0,M,N=[],P,F,I=new Map;function L(e,t){I.set(e,[...I.get(e)||[],t])}function R(e){let t=T(o),n=T(s),r=t&&n?t/n:0,u={srcEvent:i,isPanRecognized:c,isSwipeRecognized:l,firstTouch:a,previousTouch:s,currentTouch:o,deltaX:h,deltaY:g,offsetX:_,offsetY:v,velocityX:y,velocityY:b,velocity:Math.abs(y)>Math.abs(b)?y:b,angle:j,axis:M,scale:r,center:m};for(let t of I.get(e)||[])t(u)}function z(e){let t=e.target,r=e.composedPath()[0],i=n.ignore.join(`,`),a=e=>e&&e instanceof HTMLElement&&(e.matches(i)||e.closest(i));if(a(t)||a(r))return!1}function B(e){let t=Date.now();if(N=N.filter(e=>!e.ts||e.ts>t-100),e&&N.push(e),y=0,b=0,N.length>3){let e=N[0],t=N[N.length-1];if(e&&t){let n=t.x-e.x,r=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(r)>3?r/(i/30):0)}}}function V(e){if(!r||z(e)===!1)return;if(typeof MouseEvent<`u`&&e instanceof MouseEvent){if(k)return}else k=!0;if(typeof MouseEvent<`u`&&e instanceof MouseEvent){if(!e.buttons||e.button!==0)return;E(e)}e instanceof MouseEvent&&(window.addEventListener(`mousemove`,H),window.addEventListener(`mouseup`,U)),window.addEventListener(`blur`,ee),i=e,o=S(e),a=[...o],s=[],p=o.length,m=w(o),p===1&&(c=!1,l=!1,u=!1),p&&B(w(o));let t=Date.now(),n=t-(f||t);d=n>0&&n<=250&&p===1,f=t,clearTimeout(P),R(`start`)}function H(e){if(!a.length||e.defaultPrevented||z(e)===!1)return;i=e,s=[...o],o=x(e);let t=w(s),r=w(x(e));if(B(r),p=o.length,m=r,s.length===o.length?(h=r.x-t.x,g=r.y-t.y):(h=0,g=0),a.length){let e=w(a);_=r.x-e.x,v=r.y-e.y}if(o.length>1){let e=T(o),t=T(s);Math.abs(e-t)>=.1&&(u=!0,R(`pinch`))}c||(c=Math.abs(_)>=n.panThreshold||Math.abs(v)>=n.panThreshold,c&&(A=!1,clearTimeout(F),F=void 0,j=Math.abs(Math.atan2(v,_)*180/Math.PI),M=j>45&&j<135?`y`:`x`,a=[...o],s=[...o],_=0,v=0,h=0,g=0,window.getSelection()?.removeAllRanges(),R(`panstart`))),c&&(h||g)&&R(`pan`),R(`move`)}function U(e){if(i=e,!a.length)return;let t=S(e),r=C(e);if(p=t.length,m=w(r),r.length&&B(w(r)),s=[...o],o=[...t],a=[...t],p>0)R(`end`),c=!1,l=!1,N=[];else{let e=n.swipeThreshold;(Math.abs(y)>e||Math.abs(b)>e)&&(l=!0),c&&R(`panend`),l&&R(`swipe`),!c&&!l&&!u&&(R(`tap`),d?R(`doubleTap`):P=setTimeout(function(){R(`singleTap`)},250)),R(`end`),W()}}function ee(){clearTimeout(P),W(),c&&R(`panend`),R(`end`)}function W(){k=!1,c=!1,l=!1,d=!1,p=0,N=[],o=[],s=[],a=[],h=0,g=0,_=0,v=0,y=0,b=0,j=0,M=void 0,window.removeEventListener(`mousemove`,H),window.removeEventListener(`mouseup`,U),window.removeEventListener(`blur`,ee),!A&&!F&&(F=setTimeout(()=>{A=!0,F=void 0},100))}function te(e){let t=e.target;k=!1,t&&!e.defaultPrevented&&(A||(E(e),e.stopPropagation()))}function ne(){return e&&(e.addEventListener(`click`,te,D),e.addEventListener(`mousedown`,V,D),e.addEventListener(`touchstart`,V,D),e.addEventListener(`touchmove`,H,D),e.addEventListener(`touchend`,U),e.addEventListener(`touchcancel`,U)),G}let G={init:ne,on:function(e,t){return L(e,t),G},off:function(e,t){return I.has(e)&&I.set(e,I.get(e).filter(e=>e!==t)),G},enable:function(){return r=!0,G},disable:function(){return r=!1,a.length&&(l=!1,y=0,b=0,h=0,g=0,R(`end`)),W(),G},isPointerDown:()=>p>0,destroy:function(){clearTimeout(P),clearTimeout(F),F=void 0,e&&(e.removeEventListener(`click`,te,D),e.removeEventListener(`mousedown`,V,D),e.removeEventListener(`touchstart`,V,D),e.removeEventListener(`touchmove`,H,D),e.removeEventListener(`touchend`,U),e.removeEventListener(`touchcancel`,U)),e=null,W()}};return G};j.isClickAllowed=()=>A;let M={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`,TOGGLE_FS:`Toggle fullscreen`},N=(e,t=``)=>{e&&e.classList&&t.split(` `).forEach(t=>{t&&e.classList.add(t)})},P=(e,t=``)=>{e&&e.classList&&t.split(` `).forEach(t=>{t&&e.classList.remove(t)})},F=(e,t=``,n)=>{e&&e.classList&&t.split(` `).forEach(t=>{t&&e.classList.toggle(t,n||!1)})},I=1e4,L=e=>{e.cancelable&&e.preventDefault()},R=(e,t=I)=>(e=parseFloat(e+``)||0,Math.round((e+2**-52)*t)/t),z=e=>e instanceof HTMLImageElement;var B;(function(e){e.Reset=`reset`,e.Zoom=`zoom`,e.ZoomIn=`zoomIn`,e.ZoomOut=`zoomOut`,e.ZoomTo=`zoomTo`,e.ToggleCover=`toggleCover`,e.ToggleFull=`toggleFull`,e.ToggleMax=`toggleMax`,e.IterateZoom=`iterateZoom`,e.Pan=`pan`,e.Swipe=`swipe`,e.Move=`move`,e.MoveLeft=`moveLeft`,e.MoveRight=`moveRight`,e.MoveUp=`moveUp`,e.MoveDown=`moveDown`,e.RotateCCW=`rotateCCW`,e.RotateCW=`rotateCW`,e.FlipX=`flipX`,e.FlipY=`flipY`,e.ToggleFS=`toggleFS`})(B||={});var V;(function(e){e.Cover=`cover`,e.Full=`full`,e.Max=`max`})(V||={});let H={x:0,y:0,scale:1,angle:0,flipX:1,flipY:1};var U;(function(e){e[e.Init=0]=`Init`,e[e.Loading=1]=`Loading`,e[e.Error=2]=`Error`,e[e.Ready=3]=`Ready`,e[e.Destroyed=4]=`Destroyed`})(U||={});let ee={bounds:!0,classes:{container:`f-panzoom`,wrapper:`f-panzoom__wrapper`,content:`f-panzoom__content`,viewport:`f-panzoom__viewport`},clickAction:B.ToggleFull,dblClickAction:!1,gestures:{},height:`auto`,l10n:M,maxScale:4,minScale:1,mouseMoveFactor:1,panMode:`drag`,protected:!1,singleClickAction:!1,spinnerTpl:`<div class="f-spinner"></div>`,wheelAction:B.Zoom,width:`auto`},W=0,te,ne=0,G=0,re=(e,t={},r={})=>{let a=0,l={...ee,...t},d={},f,p,m,h,g={...H},_={...H},y,b,x,S,T=[];function E(e){let t=l[e];return t&&typeof t==`function`?t($):t}function D(e,t=[]){let n=E(`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=e.replace(/\{\{(.*?)\}\}/g,(e,t)=>t),e}function O(){return e&&e.parentElement&&f&&a===3}let k=new Map;function A(e,t){for(let n of e instanceof Array?e:[e])k.set(n,[...k.get(n)||[],t]);return $}function M(e,t){for(let n of e instanceof Array?e:[e])k.has(n)&&k.set(n,k.get(n).filter(e=>e!==t));return $}function V(e,...t){let n=[...k.get(e)||[]];l.on&&n.push(l.on[e]);for(let e of n)e&&typeof e==`function`&&e($,...t);e!==`*`&&V(`*`,e,...t)}function U(){return a=0,V(`init`),re(),ie(),ae(),oe(),$}function re(){for(let[e,t]of Object.entries({...r,...l.plugins||{}}))if(e&&!d[e]&&t instanceof Function){let n=t();n.init($),d[e]=n}V(`initPlugins`)}function ie(){let t={...ee.classes,...E(`classes`)},n=t.content?.split(` `).shift(),r=t.wrapper?.split(` `).shift(),i=t.viewport?.split(` `).shift();if(n&&r&&i&&e&&(N(e,t.container),p=e.querySelector(`.${n}:not(.is-clone)`),p)){if(p.setAttribute(`draggable`,`false`),f=e.querySelector(`.${r}`),f||(f=document.createElement(`div`),N(f,t.wrapper),p.insertAdjacentElement(`beforebegin`,f),f.insertAdjacentElement(`afterbegin`,p)),h=e.querySelector(`.${i}`),h||(h=document.createElement(`div`),N(h,t.viewport),f.insertAdjacentElement(`beforeend`,h)),h.contains(p)||h.insertAdjacentElement(`afterbegin`,p),m=e.querySelector(`.${n}.is-clone`),m||(m=p.cloneNode(!0),m.removeAttribute(`id`),N(m,`is-clone`),f.insertAdjacentElement(`afterbegin`,m)),p instanceof HTMLPictureElement&&(p=p.querySelector(`img`)),m instanceof HTMLPictureElement&&(m=m.querySelector(`img`)),h instanceof HTMLPictureElement&&(h=h.querySelector(`img`)),h&&(h.style.visibility=`hidden`,E(`protected`))){h.addEventListener(`contextmenu`,e=>{L(e)});let e=document.createElement(`div`);N(e,`f-panzoom__protected`),h.appendChild(e)}V(`initLayout`)}}function ae(){if(e&&f&&!x){let e=null;x=new ResizeObserver(()=>{O()&&(e||=requestAnimationFrame(()=>{O()&&(X(),Ee(),V(`refresh`)),e=null}))}),x.observe(f),T.push(()=>{x?.disconnect(),x=void 0,e&&=(cancelAnimationFrame(e),null)})}}function oe(){if(!e||!p)return;if(!(z(p)&&z(m))){ge();return}let t=()=>{p&&z(p)&&p.decode().then(()=>{ge()}).catch(()=>{ge()})};if(a=1,e.classList.add(`is-loading`),V(`loading`),m.src&&m.complete){t();return}me(),m.addEventListener(`load`,t,!1),m.addEventListener(`error`,t,!1),T.push(()=>{m?.removeEventListener(`load`,t,!1),m?.removeEventListener(`error`,t,!1)})}function se(){b=v().on(`start`,(e,t)=>{t.angle!==void 0&&(t.angle=Math.round(t.angle/90)*90),t.flipX!==void 0&&(t.flipX=t.flipX>0?1:-1),t.flipY!==void 0&&(t.flipY=t.flipY>0?1:-1),_={...H,...t},X(),V(`animationStart`)}).on(`pause`,e=>{_={...H,...e}}).on(`step`,e=>{if(!O()){b?.end();return}if(g={...H,...e},K()||!E(`bounds`)||Ue()||_.scale>g.scale||_.scale<J()){De();return}let t=Te(_.scale),n=!1,r=!1,i=!1,a=!1;g.x<t.x[0]&&(n=!0),g.x>t.x[1]&&(r=!0),g.y<t.y[0]&&(a=!0),g.y>t.y[1]&&(i=!0);let o=!1,s=!1,l=!1,u=!1;_.x<t.x[0]&&(o=!0),_.x>t.x[1]&&(s=!0),_.y<t.y[0]&&(u=!0),_.y>t.y[1]&&(l=!0);let d=!1;(r&&s||n&&o)&&(_.x=c(t.x[0],_.x,t.x[1]),d=!0),(i&&l||a&&u)&&(_.y=c(t.y[0],_.y,t.y[1]),d=!0),d&&b&&b.spring({tension:94,friction:17,maxSpeed:555*_.scale,restDelta:.1,restSpeed:.1,velocity:b.getCurrentVelocities()}).from(g).to(_).start(),De()}).on(`end`,()=>{y?.isPointerDown()||Ee(),b?.isRunning()||(X(),V(`animationEnd`))})}function ce(){let e=E(`gestures`);if(!e||!h||!p)return;let t=!1;y=j(h,e).on(`start`,e=>{if(!E(`gestures`)||!b||!O()||K())return;let n=e.srcEvent;(g.scale>1||Q(g.angle)||e.currentTouch.length>1)&&(n?.stopPropagation(),b.pause(),t=!0),e.currentTouch.length===1&&V(`touchStart`)}).on(`move`,e=>{t&&(_.scale!==1||Q(_.angle)||e.currentTouch.length>1)&&(L(e.srcEvent),e.srcEvent?.stopPropagation())}).on(`pan`,e=>{if(!t)return;let n=e.srcEvent;(_.scale!==1||Q(_.angle)||e.currentTouch.length>1)&&(L(n),Z(B.Pan,e))}).on(`swipe`,e=>{t&&(_.scale>1||Q(_.angle))&&Z(B.Swipe,e)}).on(`tap`,e=>{V(`click`,e)}).on(`singleTap`,e=>{V(`singleClick`,e)}).on(`doubleTap`,e=>{V(`dblClick`,e)}).on(`pinch`,e=>{t&&(e.scale>J()?Z(B.ZoomIn,e):e.scale<J()?Z(B.ZoomOut,e):Z(B.Pan,e))}).on(`end`,e=>{t&&(e.currentTouch.length?(e.srcEvent.stopPropagation(),L(e.srcEvent),b?.end()):(t=!1,X(),Ee(),V(`touchEnd`)))}).init()}function le(){h&&(h.addEventListener(`wheel`,ue,{passive:!1}),T.push(()=>{h?.removeEventListener(`wheel`,ue,{passive:!1})}))}function ue(e){if(!O())return;let t=e.target;if(o(t))return;let n=Date.now(),r=[-e.deltaX||0,-e.deltaY||0,-e.detail||0].reduce(function(e,t){return Math.abs(t)>Math.abs(e)?t:e}),i=c(-1,r,1);V(`wheel`,e,i);let a=E(`wheelAction`);if(!a||e.defaultPrevented)return;let s=_.scale,l=s*(i>0?1.5:.5);if(a===B.Zoom){let t=Math.abs(e.deltaY)<100&&Math.abs(e.deltaX)<100?200:45;if(n-ne<t){L(e);return}ne=n;let r=Se(),a=Y();if(R(l)<R(r)&&R(s)<=R(r)?(G+=Math.abs(i),l=r):R(l)>R(a)&&R(s)>=R(a)?(G+=Math.abs(i),l=a):(G=0,l=c(r,l,a)),G>7)return}switch(L(e),a){case B.Pan:Z(a,{srcEvent:e,deltaX:-e.deltaX*2,deltaY:-e.deltaY*2});break;case B.Zoom:Z(B.ZoomTo,{srcEvent:e,scale:l,center:{x:e.clientX,y:e.clientY}});break;default:Z(a,{srcEvent:e})}}function de(t){let n=t.composedPath()[0];if(!j.isClickAllowed()||!i(n)||t.defaultPrevented||!e?.contains(n)||n.hasAttribute(`disabled`)||n.hasAttribute(`aria-disabled`)||n.hasAttribute(`data-carousel-go-prev`)||n.hasAttribute(`data-carousel-go-next`))return;let r=n.closest(`[data-panzoom-action]`),a=r?.dataset?.panzoomAction,o=r?.dataset?.panzoomValue||``;if(a){switch(L(t),a){case B.ZoomTo:case B.ZoomIn:case B.ZoomOut:Z(a,{scale:parseFloat(o||``)||void 0});break;case B.MoveLeft:case B.MoveRight:Z(a,{deltaX:parseFloat(o||``)||void 0});break;case B.MoveUp:case B.MoveDown:Z(a,{deltaY:parseFloat(o||``)||void 0});break;case B.ToggleFS:Ke();break;default:Z(a)}return}if(!f?.contains(n))return;let s={srcEvent:t};if(Z(E(`clickAction`),s),E(`dblClickAction`)){let e=Date.now(),t=e-(W||e),n=t>0&&t<=250;W=e,n?(te&&=(clearTimeout(te),void 0),Z(E(`dblClickAction`),s)):te=setTimeout(()=>{Z(E(`singleClickAction`),s)},250)}}function fe(e){if(S=e,!O()||!K()||g.scale<=1||_.scale<=1||(f?.dataset.animationName||``).indexOf(`zoom`)>-1)return;let t=xe(_.scale);if(!t)return;let{x:n,y:r}=t;Z(B.Pan,{deltaX:n-_.x,deltaY:r-_.y})}function pe(){e?.addEventListener(`click`,de),document?.addEventListener(`mousemove`,fe),T.push(()=>{e?.removeEventListener(`click`,de),document?.removeEventListener(`mousemove`,fe)})}function me(){if(!e||e?.querySelector(`.f-spinner`))return;let t=E(`spinnerTpl`),n=s(t);n&&(n.classList.add(`f-spinner`),e.classList.add(`is-loading`),f?.insertAdjacentElement(`afterbegin`,n))}function he(){e&&(P(e,`is-loading`),e.querySelector(`.f-spinner`)?.remove())}function ge(){if(!e||!p)return;if(he(),z(p)&&!(p.complete&&p.naturalWidth)){a=2,f?.classList.add(`has-error`),V(`error`);return}V(`loaded`);let{width:t,height:n}=ye();z(p)&&(p.setAttribute(`width`,t+``),p.setAttribute(`height`,n+``)),f&&(P(f,`has-error`),z(p)&&(f.setAttribute(`width`,t+``),f.setAttribute(`height`,n+``),f.style.aspectRatio=`${t/n||``}`)),se(),ce(),le(),pe();let r=_e();g={...r},_={...r},a=3,De(),X(),V(`ready`),requestAnimationFrame(()=>{a===3&&(he(),h&&(h.style.visibility=``))})}function _e(){let e={...E(`startPos`)||{}},t=e.scale,n=1;n=typeof t==`string`?q(t):typeof t==`number`?t:J();let r={...H,...e,scale:n},i=K()?xe(n):void 0;if(i){let{x:e,y:t}=i;r.x=e,r.y=t}return r}function ve(){let e={top:0,left:0,width:0,height:0};if(f){let t=f.getBoundingClientRect();Q(_.angle)?(e.top=t.top+t.height*.5-t.width*.5,e.left=t.left+t.width*.5-t.height*.5,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 ye(){let e=E(`width`),t=E(`height`);if(p&&e===`auto`){let t=p.getAttribute(`width`);e=t?parseFloat(t+``):p.dataset.width===void 0?z(h)?h.naturalWidth:z(p)?p.naturalWidth:f?.getBoundingClientRect().width||0:parseFloat(p.dataset.width+``)}else e=n(e)?parseFloat(e):e;if(p&&t===`auto`){let e=p.getAttribute(`height`);t=e?parseFloat(e+``):p.dataset.height===void 0?z(h)?h.naturalHeight:z(p)?p.naturalHeight:f?.getBoundingClientRect().height||0:parseFloat(p.dataset.height+``)}else t=n(t)?parseFloat(t):t;return{width:e,height:t}}function be(){let e=ve();return{width:e.width,height:e.height}}function K(){return E(`panMode`)===`mousemove`&&matchMedia(`(hover: hover)`).matches}function xe(e){let t=S||E(`event`),n=f?.getBoundingClientRect();if(!t||!n||e<=1)return{x:0,y:0};let r=(t.clientX||0)-n.left,i=(t.clientY||0)-n.top,{width:a,height:o}=be(),s=Te(e);if(e>1){let t=E(`mouseMoveFactor`);t>1&&(e*=t)}let l=a*e,u=o*e,d=(l-a)*.5-(l-a)*(r/a*100/100),p=(u-o)*.5-(u-o)*(i/o*100/100);return d=c(s.x[0],d,s.x[1]),p=c(s.y[0],p,s.y[1]),{x:d,y:p}}function q(t){if(!t)return _.scale;if(!e)return 1;let n=e.getBoundingClientRect(),r=ve(),{width:i,height:a}=ye(),o=e=>{if(typeof e==`number`)return e;switch(e){case`min`:return 1;case`base`:return 1;case`cover`:return Math.max(n.height/r.height,n.width/r.width)||1;case`full`:case`max`:{let e=Q(_.angle)?a:i;return e&&r.width?e/r.width:1}}},s=E(`minScale`),l=E(`maxScale`),u=Math.min(o(`full`),o(s)),d=typeof l==`number`?o(`full`)*l:Math.min(o(`full`),o(l));switch(t){case`min`:return u;case`base`:return c(u,1,d);case`cover`:return o(`cover`);case`full`:return Math.min(d,o(`full`));case`max`:return d}}function Se(){return q(`min`)}function J(){return q(`base`)}function Ce(){return q(`cover`)}function we(){return q(`full`)}function Y(){return q(`max`)}function Te(t){let n={x:[0,0],y:[0,0]},r=e?.getBoundingClientRect();if(!r)return n;let i=ve(),a=r.width,o=r.height,s=i.width,c=i.height;t=t===void 0?_.scale:t;let l=t,u=t;if(K()&&t>1){let e=E(`mouseMoveFactor`);e>1&&(s*t>a+.01&&(l*=e),c*t>o+.01&&(u*=e))}if(s*=l,c*=u,s>a){n.x[0]=(a-s)*.5,n.x[1]=(s-a)*.5;let e=(i.left-r.left)*.5,t=(i.left+i.width-r.right)*.5;n.x[0]-=e+t,n.x[1]-=e+t}if(c>o){n.y[0]=(o-c)*.5,n.y[1]=(c-o)*.5;let e=(i.top-r.top)*.5,t=(i.top+i.height-r.bottom)*.5;n.y[0]-=e+t,n.y[1]-=e+t}return n}function Ee(){if(!O()||!E(`bounds`)||!b)return;let e=Se(),t=Y(),n=c(e,_.scale,t);if(_.scale<e-.01||_.scale>t+.01){Z(B.ZoomTo,{scale:n});return}if(b.isRunning()||Ue())return;let r=Te(n);_.x<r.x[0]||_.x>r.x[1]||_.y<r.y[0]||_.y>r.y[1]?(_.x=c(r.x[0],_.x,r.x[1]),_.y=c(r.y[0],_.y,r.y[1]),b.spring({tension:170,friction:17,restDelta:.001,restSpeed:.001,maxSpeed:1/0,velocity:b.getCurrentVelocities()}),b.from(g).to(_).start()):De()}function X(t){if(!O())return;let n=He(),r=Ue(),i=We(),a=Ge(),o=Le(),s=Re();F(f,`is-fullsize`,a),F(f,`is-expanded`,i),F(f,`is-dragging`,r),F(f,`can-drag`,n),F(f,`will-zoom-in`,o),F(f,`will-zoom-out`,s);let c=Be(),l=Ve(),u=ze(),d=!O();for(let n of(t||e)?.querySelectorAll(`[data-panzoom-action]`)||[]){let e=n.dataset.panzoomAction,t=!1;if(d)t=!0;else switch(e){case B.ZoomIn:c||(t=!0);break;case B.ZoomOut:u||(t=!0);break;case B.ToggleFull:{l||u||(t=!0);let e=n.querySelector(`g`);e&&(e.style.display=a&&!t?`none`:``);break}case B.IterateZoom:{c||u||(t=!0);let e=n.querySelector(`g`);e&&(e.style.display=!c&&!t?`none`:``);break}case B.ToggleCover:case B.ToggleMax:c||u||(t=!0)}t?(n.setAttribute(`aria-disabled`,``),n.setAttribute(`tabindex`,`-1`)):(n.removeAttribute(`aria-disabled`),n.removeAttribute(`tabindex`))}}function Z(t,n){if(!t||!e||!p||!b||!O()||t===B.Swipe&&Math.abs(b.getCurrentVelocities().scale)>.01)return;let r={..._},i={..._},a=Te(K()?r.scale:g.scale),o=b.getCurrentVelocities(),s=ve();n||={};let l=(n.currentTouch?.length||0)>1,d=n.velocityX||0,f=n.velocityY||0,m=n.center;n.srcEvent&&(m=w(C(n.srcEvent)));let h=n.deltaX||0,v=n.deltaY||0;switch(t){case B.MoveRight:h=n.deltaX||100;break;case B.MoveLeft:h=n.deltaX||-100;break;case B.MoveUp:v=n.deltaY||-100;break;case B.MoveDown:v=n.deltaY||100}let y=[];if(typeof t==`number`)i.scale=t;else switch(t){case B.Reset:i={...H},i.scale=J();break;case B.ZoomTo:case B.ZoomIn:case B.ZoomOut:case B.ToggleCover:case B.ToggleFull:case B.ToggleMax:case B.IterateZoom:case B.Zoom:i.scale=Ie(t,n);break;case B.Pan:case B.Move:case B.MoveLeft:case B.MoveRight:case B.MoveUp:case B.MoveDown:if(Ue()){let e=1,t=1;i.x<=a.x[0]&&d<=0&&(e=Math.max(.01,1-Math.abs(1/s.width*Math.abs(i.x-a.x[0]))),e*=.2),i.x>=a.x[1]&&d>=0&&(e=Math.max(.01,1-Math.abs(1/s.width*Math.abs(i.x-a.x[1]))),e*=.2),i.y<=a.y[0]&&f<=0&&(t=Math.max(.01,1-Math.abs(1/s.height*Math.abs(i.y-a.y[0]))),t*=.2),i.y>=a.y[1]&&f>=0&&(t=Math.max(.01,1-Math.abs(1/s.height*Math.abs(i.y-a.y[1]))),t*=.2),i.x+=h*e,i.y+=v*t}else i.x=c(a.x[0],i.x+h,a.x[1]),i.y=c(a.y[0],i.y+v,a.y[1]);break;case B.Swipe:let e=(e=0)=>Math.sign(e)*Math.abs(e)**1.5;i.x+=c(-1e3,e(d),1e3),i.y+=c(-1e3,e(f),1e3),f&&!d&&(i.x=c(a.x[0],i.x,a.x[1])),!f&&d&&(i.y=c(a.y[0],i.y,a.y[1])),o.x=d,o.y=f;break;case B.RotateCW:i.angle+=90;break;case B.RotateCCW:i.angle-=90;break;case B.FlipX:i.flipX*=-1;break;case B.FlipY:i.flipY*=-1}if(g.angle!==void 0&&Math.abs(g.angle)>=360&&(i.angle-=Math.floor(g.angle/360)*360,g.angle-=Math.floor(g.angle/360)*360),y.length){let e=y.findIndex(e=>e>i.scale+1/I);i.scale=y[e]||y[0]}if(l&&(i.scale=c(Se()*(l?.8:1),i.scale,Y()*(l?1.6:1))),K()){let e=xe(i.scale);if(e){let{x:t,y:n}=e;i.x=t,i.y=n}}else if(Math.abs(i.scale-r.scale)>1e-4){let t=0,n=0;if(m)t=m.x,n=m.y;else{let r=e.getBoundingClientRect();t=r.x+r.width*.5,n=r.y+r.height*.5}let o=t-s.left,u=n-s.top;o-=s.width*.5,u-=s.height*.5;let d=(o-r.x)/r.scale,f=(u-r.y)/r.scale;i.x=o-d*i.scale,i.y=u-f*i.scale,!l&&E(`bounds`)&&(a=Te(i.scale),i.x=c(a.x[0],i.x,a.x[1]),i.y=c(a.y[0],i.y,a.y[1]))}if(t===B.Swipe){let e=500*i.scale,t=o;b.spring({tension:94,friction:17,maxSpeed:e,restDelta:.1,restSpeed:.1,velocity:t})}else t===B.Pan||l?b.spring({tension:900,friction:17,restDelta:.01,restSpeed:.01,maxSpeed:1}):b.spring({tension:170,friction:17,restDelta:.001,restSpeed:.001,maxSpeed:1/0,velocity:o});if(n.velocity===0||u(g,i))g={...i},_={...i},b.end(),De(),X();else{if(u(_,i))return;b.from(g).to(i).start()}V(`action`,t)}function De(){if(!p||!f||!h)return;let{width:e,height:t}=ye();Object.assign(f.style,{maxWidth:`min(${e}px, 100%)`,maxHeight:`min(${t}px, 100%)`});let{x:n,y:r,width:i,height:a,scale:o,angle:s,flipX:c,flipY:l}=Oe(),u=`translate(${R(n,100)}px, ${R(r,100)}px)`;u+=c!==1||l!==1?` scaleX(${R(o*c)}) scaleY(${R(o*l)})`:` scale(${R(o)})`,s!==0&&(u+=` rotate(${s}deg)`),h.style.width=`${R(i)}px`,h.style.height=`${R(a)}px`,h.style.transform=`${u}`,V(`render`)}function Oe(){let{width:t,height:n}=ye(),{width:r,height:i}=be();if(!e)return{x:0,y:0,width:0,height:0,scale:0,flipX:0,flipY:0,angle:0,fitWidth:r,fitHeight:i,fullWidth:t,fullHeight:n};let{x:a,y:o,scale:s,angle:c,flipX:l,flipY:u}=g,d=1/we(),f=t,p=n,m=g.scale*d,h=_.scale*d,v=Math.max(r,i),y=Math.min(r,i);t>n?(f=v,p=y):(f=y,p=v),m=t>n?v*s/t||1:v*s/n||1;let b=f?t*h:0,x=p?n*h:0,S=f&&p?t*m/b:0;return a=a+f*.5-b*.5,o=o+p*.5-x*.5,{x:a,y:o,width:b,height:x,scale:S,flipX:l,flipY:u,angle:c,fitWidth:r,fitHeight:i,fullWidth:t,fullHeight:n}}function ke(){return b}function Ae(){return y}function je(){return e}function Me(){return p}function Ne(){return f}function Pe(){return h}function Fe(){V(`destroy`);for(let e of Object.values(d))e?.destroy($);for(let e of T)e();return f&&(f.style.aspectRatio=``,f.style.maxWidth=``,f.style.maxHeight=``),h&&(h.style.width=``,h.style.height=``,h.style.transform=``),f=void 0,p=void 0,h=void 0,g={...H},_={...H},b?.destroy(),b=void 0,y?.destroy(),y=void 0,a=4,$}function Ie(e=E(`clickAction`),t={}){let n=_.scale,r=J(),i=[];if(typeof e==`number`)r=e;else if(e){switch(e){case B.ZoomTo:r=t.scale||1;break;case B.ZoomIn:r=n*(t.scale||2);break;case B.ZoomOut:r=n*(t.scale||.5);break;case B.ToggleCover:i=[J(),Ce()];break;case B.ToggleFull:i=[J(),we()];break;case B.ToggleMax:i=[J(),Y()];break;case B.IterateZoom:i=[J(),we(),Y()];break;case B.Zoom:{let e=we();r=n>=e-.05?J():Math.min(e,n*(t.scale||2));break}}i.length&&(r=i.find(e=>e>n+1/I)??J())}return e!==B.ZoomTo&&(r=c(Se(),r,Y())),r}function Le(){return!!(O()&&Ie()>_.scale)}function Re(){return!!(O()&&Ie()<_.scale)}function ze(){return!!(O()&&_.scale>Se())}function Be(){return!!(O()&&_.scale<Y())}function Ve(){return!!(O()&&_.scale<we())}function He(){return!!(O()&&(We()||Q(_.angle))&&y&&!K())}function Q(e){return Math.abs(e%180)===90}function Ue(){return!!(O()&&y?.isPointerDown()&&!K())}function We(){return!!(O()&&_.scale>J())}function Ge(){return!!(O()&&_.scale>=we())}function Ke(){let t=`in-fullscreen`,n=`with-panzoom-in-fullscreen`;e?.classList.toggle(t);let r=e?.classList.contains(t);r?(document.documentElement.classList.add(n),document.addEventListener(`keydown`,qe,!0)):(document.documentElement.classList.remove(n),document.removeEventListener(`keydown`,qe,!0)),De(),V(r?`enterFS`:`exitFS`)}function qe(e){e.key===`Escape`&&!e.defaultPrevented&&Ke()}let $={canDrag:He,canZoomIn:Be,canZoomOut:ze,canZoomToFull:Ve,destroy:Fe,emit:V,execute:Z,getBoundaries:Te,getContainer:je,getContent:Me,getFullDim:ye,getGestures:Ae,getMousemovePos:xe,getOptions:function(){return l},getPlugins:function(){return d},getScale:q,getStartPosition:_e,getState:function(){return a},getTransform:function(e){return e===!0?_:g},getTween:ke,getViewport:Pe,getWrapper:Ne,init:U,isDragging:Ue,isExpanded:We,isFullsize:Ge,isMousemoveMode:K,localize:D,off:M,on:A,toggleFS:Ke,updateControls:X,version:`6.1.15`,willZoomIn:Le,willZoomOut:Re};return $};re.l10n={en_EN:M},re.getDefaults=()=>ee;let ie={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 i(n,r){let i=e?.getOptions().Zoomable,a=(t(i)?{...ie,...i}:ie)[n];return a&&typeof a==`function`&&r?a(r):a}function a(){e&&e.getOptions().Zoomable!==!1&&(e.on(`addSlide`,c),e.on(`removeSlide`,l),e.on(`attachSlideEl`,u),e.on(`click`,s),e.on(`change`,o),e.on(`ready`,o))}function o(){d();let t=e?.getVisibleSlides()||[];if(t.length>1||e?.getOption(`transition`)===`slide`)for(let n of t){let t=n.panzoomRef;t&&(e?.getPage().slides||[]).indexOf(n)<0&&t.execute(B.ZoomTo,{...t.getStartPosition()})}}function s(e,t){let n=t.target;n&&!t.defaultPrevented&&n.dataset.panzoomAction&&f(n.dataset.panzoomAction)}function c(t,a){let o=a.el;if(!e||!o||a.panzoomRef)return;let s=a.src||a.lazySrc||``,c=a.alt||a.caption||`Image #${a.index}`,l=a.srcset||a.lazySrcset||``,u=a.sizes||a.lazySizes||``;if(s&&n(s)&&!a.html&&(!a.type||a.type===`image`)){a.type=`image`,a.thumbSrc=a.thumbSrc||s;let e=i(`tpl`,a);e=r(e,`{{src}}`,s+``),e=r(e,`{{srcset}}`,l+``),e=r(e,`{{sizes}}`,u+``),o.insertAdjacentHTML(`afterbegin`,e)}let f=o.querySelector(`.f-panzoom__content`);if(!f)return;f.setAttribute(`alt`,c+``);let p=a.width&&a.width!==`auto`?parseFloat(a.width+``):`auto`,m=a.height&&a.height!==`auto`?parseFloat(a.height+``):`auto`,h=re(o,{width:p,height:m,classes:{container:`f-zoomable`},event:()=>e?.getLastMouseMove(),spinnerTpl:()=>e?.getOption(`spinnerTpl`)||``,...i(`Panzoom`)});h.on(`*`,(t,n,...r)=>{e&&(n===`loading`&&(a.state=0),n===`loaded`&&(a.state=1),n===`error`&&(a.state=2,e?.showError(a,`{{IMAGE_ERROR}}`)),e.emit(`panzoom:${n}`,a,...r),n===`loading`&&e.emit(`contentLoading`,a),n===`ready`&&e.emit(`contentReady`,a),a.index===e?.getPageIndex()&&d())}),a.panzoomRef=h}function l(e,t){t.panzoomRef&&=(t.panzoomRef.destroy(),void 0)}function u(e,t){let n=t.panzoomRef;if(n)switch(n.getState()){case 0:n.init();break;case 3:n.execute(B.ZoomTo,{...n.getStartPosition(),velocity:0})}}function d(){let t=e?.getContainer()||void 0,n=e?.getPage()?.slides[0]?.panzoomRef;if(t){if(n)n.updateControls(t);else for(let e of t.querySelectorAll(`[data-panzoom-action]`)||[])e.setAttribute(`aria-disabled`,``),e.setAttribute(`tabindex`,`-1`)}}function f(t,...n){e?.getPage().slides[0].panzoomRef?.execute(t,...n)}return{init:function(t){e=t,e.on(`initPlugins`,a)},destroy:function(){if(e){e.off(`initPlugins`,a),e.off(`addSlide`,c),e.off(`removeSlide`,l),e.off(`attachSlideEl`,u),e.off(`click`,s),e.off(`change`,o),e.off(`ready`,o);for(let t of e.getSlides())l(e,t)}e=void 0},execute:f}}});