UNPKG

@fancyapps/ui

Version:

Robust JavaScript UI Component Library

1 lines 29.6 kB
!/*! 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),i=e=>e&&null!==e&&e instanceof Element&&"nodeType"in e,r=function(e){if(!(e&&e instanceof Element&&e.offsetParent))return!1;let t=e.scrollHeight>e.clientHeight,n=window.getComputedStyle(e).overflowY,i=-1!==n.indexOf("hidden"),r=-1!==n.indexOf("visible");return t&&!i&&!r},o=function(e,t){return!e||e===document.body||t&&e===t?null:r(e)?e:o(e.parentElement,t)},l=(e,t)=>{let n=[];return e.childNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&(!t||e.matches(t))&&n.push(e)}),n},s=(e,...t)=>{let i=t.length;for(let r=0;r<i;r++)Object.entries(t[r]||{}).forEach(([t,i])=>{let r=Array.isArray(i)?[]:{};e[t]||Object.assign(e,{[t]:r}),n(i)?Object.assign(e[t],s(e[t],i)):Array.isArray(i)?Object.assign(e,{[t]:[...i]}):Object.assign(e,{[t]:i})});return e},a=function(e=0,t=0,n=0){return Math.max(Math.min(t,n),e)},u=function(e=0,t=0,n=0,i=0,r=0,o=!1){let l=(e-t)/(n-t)*(r-i)+i;return o?i<r?a(i,l,r):a(r,l,i):l},f=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 i=t.firstChild;if(i&&!(i instanceof HTMLElement)){var n=document.createElement("div");return n.appendChild(i),n}return i},d=(e,t="")=>{e&&e.classList&&t.split(" ").forEach(t=>{t&&e.classList.add(t)})},c=(e,t="")=>{e&&e.classList&&t.split(" ").forEach(t=>{t&&e.classList.remove(t)})},p=(e,t="",n)=>{e&&e.classList&&t.split(" ").forEach(t=>{t&&e.classList.toggle(t,n||!1)})};function g(e){return n(e)||Array.isArray(e)}function h(e,t){let n=Object.keys(e),i=Object.keys(t);return n.length===i.length&&n.every(n=>{let i=e[n],r=t[n];return"function"==typeof i?`${i}`==`${r}`:g(i)&&g(r)?h(i,r):i===r})}let m=1/60*3e3,v=function(e){for(let t of S)t.getState()===E.Running&&t.tick(R?e-R:0);R=e,O=window.requestAnimationFrame(v)},E=((b={})[b.Initializing=0]="Initializing",b[b.Running=1]="Running",b[b.Paused=2]="Paused",b[b.Completed=3]="Completed",b[b.Destroyed=4]="Destroyed",b);var b,y,M,w,L,x=((y=x||{})[y.Spring=0]="Spring",y[y.Ease=1]="Ease",y);let T=((M={})[M.Loop=0]="Loop",M[M.Reverse=1]="Reverse",M),S=new Set,O=null,R=0;function A(){let e=E.Initializing,t=x.Ease,n=0,i=0,r=A.Easings.Linear,o=500,l=0,s=0,u=0,f=0,d=1/0,c=.01,p=.01,g=!1,b={},y=null,M={},w={},L={},R=0,P=0,C=T.Loop,D=A.Easings.Linear,V=new Map;function I(e,...t){for(let n of V.get(e)||[])n(...t)}function j(e){return i=0,e?y=setTimeout(()=>{H()},e):H(),z}function H(){e=E.Running,I("start",M,w)}function _(){if(e=E.Completed,L={},I("end",M),e===E.Completed)if(n<R){if(n++,C===T.Reverse){let e={...b};b={...w},w=e}j(P)}else n=0;return z}let z={getState:function(){return e},easing:function(e){return r=e,t=x.Ease,L={},z},duration:function(e){return o=e,z},spring:function(e={}){t=x.Spring;let{velocity:n,mass:i,tension:r,friction:o,restDelta:a,restSpeed:h,maxSpeed:m,clamp:v}={velocity:0,mass:1,tension:170,friction:26,restDelta:.1,restSpeed:.1,maxSpeed:1/0,clamp:!0,...e};return l=n,s=i,u=r,f=o,p=a,c=h,d=m,g=v,L={},z},isRunning:function(){return e===E.Running},isSpring:function(){return t===x.Spring},from:function(e){return M={...e},z},to:function(e){return w=e,z},repeat:function(e,t=0,n=T.Loop,i){return R=e,P=t,C=n,D=i||r,z},on:function(e,t){return V.set(e,[...V.get(e)||[],t]),z},off:function(e,t){return V.has(e)&&V.set(e,V.get(e).filter(e=>e!==t)),z},start:function(t){return e=E.Initializing,h(b={...M},w)||(S.add(this),O||(O=window.requestAnimationFrame(v)),j(t)),z},pause:function(){return y&&(clearTimeout(y),y=null),e===E.Running&&(e=E.Paused,I("pause",M)),z},end:_,tick:function(n){n>m&&(n=m),i+=n;let v=0,y=!1;if(e!==E.Running)return z;if(t===x.Ease){y=1===(v=a(0,i/o,1));let e=C===T.Reverse?D:r;for(let t in M)M[t]=b[t]+(w[t]-b[t])*e(v)}if(t===x.Spring){let e=.001*n,t=0;for(let n in M){let i=w[n],r=M[n];if(!("number"==typeof i&&!isNaN(i))||!("number"==typeof r&&!isNaN(r)))continue;if(Math.abs(i-r)<=p){M[n]=i,L[n]=0;continue}L[n]||("object"==typeof l&&"number"==typeof l[n]?L[n]=l[n]:"number"==typeof l?L[n]=l:L[n]=0);let o=L[n],h=(o=a(-1*Math.abs(d),o,Math.abs(d)))*s*f,m=Math.abs(i-r)*u;o+=((r>i?-1:1)*m-h)/s*e,r+=o*e;let v=M[n]>i?r<i:r>i,E=Math.abs(o)<c&&Math.abs(i-r)<=p;g&&v&&(E=!0),E?(r=i,o=0):t++,M[n]=r,L[n]=o}y=!t}let S={...w};return I("step",M,b,w,v),y&&e===E.Running&&h(w,S)&&(e=E.Completed,_()),z},getStartValues:function(){return b},getCurrentValues:function(){return M},getCurrentVelocities:function(){return L},getEndValues:function(){return w},destroy:function(){e=E.Destroyed,y&&(clearTimeout(y),y=null),b=M=w={},S.delete(this)}};return z}function P(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 C(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 D(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}A.destroy=()=>{for(let e of S)e.destroy();O&&(cancelAnimationFrame(O),O=null)},A.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 V=e=>{e.cancelable&&e.preventDefault()},I={passive:!1},j={panThreshold:5,swipeThreshold:3,ignore:["textarea","input","select","[contenteditable]","[data-selectable]","[data-draggable]"]},H=!1,_=!0,z=(e,t)=>{let n,i,r,o={...j,...t},l=[],s=[],a=[],u=!1,f=!1,d=!1,c=0,p=0,g=0,h=0,m=0,v=0,E=0,b=0,y=0,M=[],w=0,L=0,x=new Map;function T(e){let t=D(s),o=D(a),d=Math.abs(E)>Math.abs(b)?E:b,c={srcEvent:r,isPanRecognized:u,isSwipeRecognized:f,firstTouch:l,previousTouch:a,currentTouch:s,deltaX:g,deltaY:h,offsetX:m,offsetY:v,velocityX:E,velocityY:b,velocity:d,angle:y,axis:i,scale:t&&o?t/o:0,center:n};for(let t of x.get(e)||[])t(c)}function S(e){let t=Date.now();M=M.filter(e=>!e.ts||e.ts>t-100),e&&M.push(e)}function O(){if(E=0,b=0,M.length>3){let e=M[0],t=M[M.length-1];if(e&&t){let n=t.x-e.x,i=t.y-e.y,r=e.ts&&t.ts?t.ts-e.ts:0;r>0&&(E=Math.abs(n)>3?n/(r/30):0,b=Math.abs(i)>3?i/(r/30):0)}}}function R(e){if(e instanceof MouseEvent){if(H)return}else H=!0;let t=e.composedPath()[0],i=o.ignore.join(",");if(t.matches(i)||t.closest(i)||"undefined"!=typeof MouseEvent&&e instanceof MouseEvent&&(!e.buttons||0!==e.button))return;e instanceof MouseEvent&&V(e);let g=Date.now(),h=g-(c||g);d=h>0&&h<=250,c=g,clearTimeout(w),r=e,e instanceof MouseEvent&&(window.addEventListener("mousemove",A),window.addEventListener("mouseup",z)),window.addEventListener("blur",F),l=[...s=P(e)],a=[],p=s.length,n=C(s),1===p&&(u=!1,f=!1),p&&S(C(s)),T("start")}function A(e){if(!l.length||e.defaultPrevented)return;r=e,a=[...s],p=(s=P(e)).length;let t=n=C(s),f=C(a);if(g=t.x-f.x,h=t.y-f.y,S(t),O(),T("move"),s.length>1&&Math.abs(D(s)-D(a))>=.1&&T("pinch"),!u&&l.length){let e=C(l);m=t.x-e.x,v=t.y-e.y,(u=Math.abs(m)>o.panThreshold||Math.abs(v)>o.panThreshold)&&(_=!1,clearTimeout(L),L=0,i=(y=Math.abs(180*Math.atan2(v,m)/Math.PI))>45&&y<135?"y":"x",l=[...s],a=[...s],window.getSelection()?.removeAllRanges(),T("panstart"))}u&&(g||h)&&T("pan")}function z(e){if(r=e,!l.length)return;let t=P(e),i=function(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}(e);if(p=t.length,n=C(i),i.length&&S(C(i)),O(),a=[...s],s=[...t],l=[...t],t.length>0)T("end"),u=!1,f=!1,M=[];else{let e=o.swipeThreshold;(Math.abs(E)>e||Math.abs(b)>e)&&(f=!0),u&&T("panend"),f&&T("swipe"),u||f||(T("tap"),d?T("doubleTap"):w=setTimeout(function(){T("singleTap")},250)),T("end"),N()}}function F(){clearTimeout(w),N(),u&&T("panend"),T("end")}function N(){u=!1,f=!1,d=!1,p=0,M=[],s=[],a=[],l=[],g=0,h=0,m=0,v=0,E=0,b=0,y=0,i=void 0,window.removeEventListener("mousemove",A),window.removeEventListener("mouseup",z),window.removeEventListener("blur",F),_||L||(L=setTimeout(()=>{_=!0,L=0},100))}function k(e){let t=e.target;H=!1,t&&!e.defaultPrevented&&(_||(V(e),e.stopPropagation()))}let G={init:function(){if(e)return e.addEventListener("click",k,I),e.addEventListener("mousedown",R,I),e.addEventListener("touchstart",R,I),e.addEventListener("touchmove",A,I),e.addEventListener("touchend",z),e.addEventListener("touchcancel",z),G},on:function(e,t){return x.set(e,[...x.get(e)||[],t]),G},off:function(e,t){return x.has(e)&&x.set(e,x.get(e).filter(e=>e!==t)),G},isPointerDown:()=>p>0,destroy:function(){clearTimeout(w),clearTimeout(L),L=0,e&&(e.removeEventListener("click",k,I),e.removeEventListener("mousedown",R,I),e.removeEventListener("touchstart",R,I),e.removeEventListener("touchmove",A,I),e.removeEventListener("touchend",z),e.removeEventListener("touchcancel",z)),e=null,N()}};return G};z.isClickAllowed=()=>_;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",ERROR:"Something went wrong. <br /> Please try again later.",NEXT:"Next page",PREV:"Previous page",GOTO:"Go to page #%d",DOWNLOAD:"Download",TOGGLE_FULLSCREEN:"Toggle full-screen mode",TOGGLE_EXPAND:"Toggle full-size mode",TOGGLE_THUMBS:"Toggle thumbnails",TOGGLE_AUTOPLAY:"Toggle slideshow"},N=e=>{e.cancelable&&e.preventDefault()},k=((w={})[w.Init=0]="Init",w[w.Ready=1]="Ready",w[w.Destroyed=2]="Destroyed",w),G=((L={})[L.Loading=0]="Loading",L[L.Loaded=1]="Loaded",L[L.Error=2]="Error",L),$={adaptiveHeight:!1,center:!0,classes:{container:"f-carousel",isEnabled:"is-enabled",isLTR:"is-ltr",isRTL:"is-rtl",isHorizontal:"is-horizontal",isVertical:"is-vertical",hasAdaptiveHeight:"has-adaptive-height",viewport:"f-carousel__viewport",slide:"f-carousel__slide",isSelected:"is-selected"},dragFree:!1,enabled:!0,errorTpl:'<div class="f-html">{{ERROR}}</div>',fill:!1,infinite:!0,initialPage:0,l10n:F,rtl:!1,slides:[],slidesPerPage:"auto",spinnerTpl:'<div class="f-spinner"></div>',transition:"fade",tween:{clamp:!0,mass:1,tension:160,friction:25,restDelta:1,restSpeed:1,velocity:0},vertical:!1},q=0,B=(e,r={},g={})=>{let h,m,v,E,b;q++;let y=k.Init,M={...$},w={...$},L={},x=null,T=null,S=!1,O=!1,R=!1,P=!1,C="height",D=0,V=!0,I=0,j=0,H=0,_=0,F="*",G=[],U=[],X=new Set,Y=[],W=[],Z=0,J=0,K=0;function Q(e,...t){let n=w[e];return n&&n instanceof Function?n(eD,...t):n}function ee(e,t=[]){let n=Q("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)}let et=new Map;function en(e,...t){let n=[...et.get(e)||[]];for(let i of(w.on&&n.push(w.on[e]),n))i&&i instanceof Function&&i(eD,...t);"*"!==e&&en("*",e,...t)}function ei(){let e=s({},$,M);s(e,$,M);let t="",i=M.breakpoints||{};if(i)for(let[n,r]of Object.entries(i))window.matchMedia(n).matches&&(t+=n,s(e,r));if(void 0===b||t!==b){if(b=t,y!==k.Init){let t=W[I]?.slides[0]?.index;for(let n of(void 0===t&&(t=w.initialSlide),e.initialSlide=t,e.slides=[],G))n.isVirtual&&e.slides.push(n)}eA(),!1!==(w=e).enabled&&(y=k.Init,en("init"),function(){for(let[e,t]of Object.entries({...g,...w.plugins||{}}))if(e&&!L[e]&&t instanceof Function){let n=t();n.init(eD,B),L[e]=n}en("initPlugins")}(),function(){if(!x)return;let e=Q("classes")||{};d(x,e.container);let t=Q("style");if(t&&n(t))for(let[e,n]of Object.entries(t))x.style.setProperty(e,n);(T=x.querySelector(`.${e.viewport}`))||(d(T=document.createElement("div"),e.viewport),T.append(...l(x,`.${e.slide}`)),x.insertAdjacentElement("afterbegin",T)),x.carousel=eD,en("initLayout")}(),function(){if(!T)return;let e=Q("classes")||{};for(let t of(G=[],[...l(T,`.${e.slide}`)].forEach(e=>{e.parentElement&&G.push(eh({el:e,isVirtual:!1,...e.dataset||{}}))}),eg(Q("slides")),G))en("addSlide",t);for(let e of G){let t=e.el;t?.parentElement&&(d(t,w.classes.slide),d(t,e.class),eS(e),en("attachSlideEl",e))}en("initSlides")}(),eb(),function(){if(x&&(x.addEventListener("click",eL,{passive:!1}),document.addEventListener("mousemove",er),!v)){let e=null;(v=new ResizeObserver(t=>{e||(e=requestAnimationFrame(()=>{(function(e){if(!x)return;if(y===k.Init){let t=e[0]?.contentBoxSize[0],n=t?.blockSize||0,i=t?.inlineSize||0;Z=n,J=i,y=k.Ready,d(x,(Q("classes")||{}).isEnabled),eR(),m=A().on("start",()=>{h&&h.isPointerDown()||(es(),eR())}).on("step",e=>{let t=D;(D=e.pos)!==t&&(V=!1,eR())}).on("end",e=>{!h?.isPointerDown()&&(D=e.pos,m&&!O&&(D<H||D>_)?m.spring({clamp:!0,mass:1,tension:200,friction:25,velocity:0,restDelta:1,restSpeed:1}).from({pos:D}).to({pos:a(H,D,_)}).start():V||(V=!0,en("settle")))}),eo(),ea(),en("ready");return}if(y!==k.Ready)return;let t=W.length;eb(),eo();let n=x.getBoundingClientRect(),i=n.height,r=n.width;if(!(t>1&&(P&&.5>Math.abs(i-Z)||!P&&.5>Math.abs(r-J))))Z=i,J=r,(!P||i)&&(P||r)&&x&&T&&(t===W.length&&h?.isPointerDown()||(Q("dragFree")&&(O||D>H&&D<_)?(es(),eR()):eO(I,{transition:!1})))})(t),e=null}))})).observe(x)}}())}}function er(e){t=e}function eo(){if(!T)return;let e=Q("gestures");if(!1===e){h&&(h.destroy(),h=void 0);return}h||(h=z(T,e).on("start",e=>{if(!m)return;let{srcEvent:t}=e;P&&o(t.target),m.pause(),m.getCurrentVelocities().pos=0;let n=W[I]?.slides[0];n&&X.has(n.index)&&n.el&&(D=(n.offset||0)+(function(e){let t=new DOMMatrixReadOnly(window.getComputedStyle(e).transform);return{width:t.m41||0,height:t.m42||0}}(n.el)[C]||0)*(R&&!P?1:-1)),eM(),!O&&(D<H||D>_)&&m.spring({clamp:!0,mass:1,tension:500,friction:25,velocity:m.getCurrentVelocities()?.pos||0,restDelta:1,restSpeed:1}).from({pos:D}).to({pos:a(H,D,_)}).start()}).on("move",e=>{let{srcEvent:t,axis:n}=e,i=e.srcEvent.target;i&&o(i)||(n||(t.stopPropagation(),t.stopImmediatePropagation()),("y"===n&&P||"x"===n&&!P)&&(N(t),t.stopPropagation()))}).on("panstart",e=>{e?.axis===(P?"y":"x")&&d(T,"is-dragging")}).on("panend",()=>{c(T,"is-dragging")}).on("pan",e=>{let{deltaX:t,deltaY:n,currentTouch:i,axis:r}=e;if(!m||i.length>1||"y"===r&&!P||"x"===r&&P)return;let o=R&&!P?1:-1,l=P?n:t,s=m?.isRunning()?m.getEndValues().pos:D,a=1;!O&&(s<=H&&l*o<0?a=.2*Math.max(.01,1-Math.abs(1/ed()*Math.abs(s-H))):s>=_&&l*o>0&&(a=.2*Math.max(.01,1-Math.abs(1/ed()*Math.abs(s-_))))),s+=l*a*o,m.spring({clamp:!0,mass:1,tension:700,friction:25,velocity:m.getCurrentVelocities()?.pos||0,restDelta:1,restSpeed:1}).from({pos:D}).to({pos:s}).start()}).on("end",e=>{let{axis:t,velocityX:n,velocityY:i,currentTouch:r}=e,o=W.length,l=Q("dragFree");if(r.length>0||!m||!o)return;let s=Q("vertical")?i:n,u=m?.isRunning()?m.getEndValues().pos:D,f=R&&!P?1:-1;if(u+=s*(l?5:1)*f,!O&&(s*f<=0&&u<H||s*f>=0&&u>_)){let e=0;Math.abs(s)>0&&(e=2*Math.abs(s),e=Math.min(.3*ed(),e)),u=a(H+-1*e,u,_+e),m.spring({clamp:!0,mass:1,tension:380,friction:25,velocity:-1*s,restDelta:1,restSpeed:1}).from({pos:D}).to({pos:u}).start();return}if(l||L.Autoscroll?.isEnabled())return void(Math.abs(s)>10?m.spring({clamp:!0,mass:1,tension:150,friction:25,velocity:-1*s,restDelta:1,restSpeed:1}).from({pos:D}).to({pos:u}).start():m.isRunning()||V||(V=!0,en("settle")));if(!(l||L.Autoscroll?.isEnabled())&&(!(e.offsetX||e.offsetY)||"y"===t&&!P||"x"===t&&P))return void eO(I,{transition:"tween"});let d=ef(u);Math.abs(s)>10&&d===I&&(s>0?d+=R&&!P?1:-1:d+=R&&!P?-1:1),eO(d,{transition:"tween",tween:{velocity:-1*s}})}).init())}function el(e="*"){let t=[];for(let n of G)("*"===e||n.class&&n.class.includes(e)||n.el&&n.el?.classList.contains(e))&&t.push(n);E=void 0,F=e,U=[...t]}function es(){if(!m)return;let e=ef(m?.isRunning()?m.getEndValues().pos:D);e!==I&&(E=I,I=e,eS(),ea(),eu(),en("change",I,E))}function ea(){if(!x)return;for(let e of(p(T,"is-draggable",!!h&&W.length>0),x.querySelectorAll("[data-carousel-index]")))e.innerHTML=I+"";for(let e of x.querySelectorAll("[data-carousel-page]"))e.innerHTML=I+1+"";for(let e of x.querySelectorAll("[data-carousel-pages]"))e.innerHTML=W.length+"";for(let e of x.querySelectorAll("[data-carousel-go-prev]"))e.toggleAttribute("aria-disabled",!eP()),eP()?e.removeAttribute("tabindex"):e.setAttribute("tabindex","-1");for(let e of x.querySelectorAll("[data-carousel-go-next]"))e.toggleAttribute("aria-disabled",!eC()),eC()?e.removeAttribute("tabindex"):e.setAttribute("tabindex","-1");let e=!1,t=W[I]?.slides[0];for(let n of(t&&(t.downloadSrc||"image"===t.type&&t.src)&&(e=!0),x.querySelectorAll("[data-carousel-download]")))n.toggleAttribute("aria-disabled",!e)}function eu(e){e||(e=W[I]?.slides[0]);let t=e.el;if(t)for(let n of t.querySelectorAll("[data-slide-index]"))n.innerHTML=e.index+1+""}function ef(e){if(!W.length||!m)return 0;let t=ec(),n=e;O?n-=Math.floor((e-W[0]?.pos)/t)*t:n=a(W[0]?.pos,e,W[W.length-1]?.pos);let i=new Map,r=0;for(let e of W){let o=Math.abs(e.pos-n),l=Math.min(o,Math.abs(e.pos-n-t),Math.abs(e.pos-n+t));i.set(r,l),r++}return parseInt((i.size>0?[...i.entries()].reduce((e,t)=>t[1]<e[1]?t:e):[I,0])[0])}function ed(){return T&&T.getBoundingClientRect()[C]||0}function ec(e=!0){return U.reduce((e,t)=>e+t.dim,0)+(U.length-(O&&e?0:1))*K}function ep(e){let t=ec(),n=ed();if(!T)return[];let i=[];if(!t||!n)return[];e=void 0===e?D:e,O&&(e-=Math.floor(e/t)*t);let r=0,o=0;if(S){let e=T.getBoundingClientRect();r=Math.abs(e.left),o=Math.abs(window.innerWidth-e.right)}let l=0;for(let s of U){let a=(t=0)=>{!(i.indexOf(s)>-1)&&(s.pos=l-e+t||0,s.offset+t>e-s.dim-r+.51&&s.offset+t<e+n+o-.51&&i.push(s))};s.offset=l,O&&(a(t),a(-1*t)),a(),l+=s.dim+K}return i}function eg(e,t){let n=[];for(let t of Array.isArray(e)?e:[e]){let e=eh({...t,isVirtual:!0});n.push(e)}for(let e of(G.splice(void 0===t?G.length:t,0,...n),eE(),n))!function(e){if(!e)return;let t=e.el;t||(e.el=t=document.createElement("div"));let n=e.html?e.html instanceof HTMLElement?e.html:f(e.html):void 0;n&&(d(n,"f-html"),e.htmlEl=n,d(t,"has-html"),t.append(n),en("contentReady",e))}(e);return el(F),n}function eh(e){return("string"==typeof e||e instanceof HTMLElement)&&(e={html:e}),{index:-1,el:void 0,class:"",isVirtual:!0,dim:0,pos:0,offset:0,html:"",src:"",...e}}function em(e){if(!T||!e)return;let t=e.el;if(t){if(t.setAttribute("index",e.index+""),t.parentElement!==T){let n;for(let i of(d(t,w.classes.slide),d(t,e.class),eS(e),G))if(i.index>e.index){n=i.el;break}T.insertBefore(t,n&&T.contains(n)?n:null),en("attachSlideEl",e)}return eu(e),t}}function ev(e){let t=e?.el;t&&(t.remove(),ey(t),en("detachSlideEl",e))}function eE(){for(let e=0;e<G.length;e++){let t=G[e],n=t.el;n&&(t.index!==e&&ey(n),n.setAttribute("index",`${e}`)),t.index=e}}function eb(){if(!x||!T)return;R=Q("rtl"),C=(P=Q("vertical"))?"height":"width";let e=Q("classes");p(x,e.isLTR,!R),p(x,e.isRTL,R),p(x,e.isHorizontal,!P),p(x,e.isVertical,P),p(x,e.hasAdaptiveHeight,Q("adaptiveHeight")),S="visible"===window.getComputedStyle(T).getPropertyValue("overflow-"+(P?"y":"x"));let t=T.getBoundingClientRect();if(!t.width&&!t.height)return;K=T&&parseFloat(getComputedStyle(T).getPropertyValue("--f-carousel-gap"))||0;let n=function(){let e=0;if(T){let t=document.createElement("div");d(t,w.classes.slide),T.appendChild(t),e=t.getBoundingClientRect()[C],t.remove(),t=void 0}return e}();for(let e of U){let t=e.el,r=0;if(!e.isVirtual&&t&&i(t)){let e=!1;t.parentElement&&t.parentElement===T||(T.appendChild(t),e=!0),r=t.getBoundingClientRect()[C],e&&t.parentElement?.removeChild(t)}else r=n;e.dim=r}if(O=!1,Q("infinite")){O=!0;let e=ec(),t=ed();if(S){let e=T.getBoundingClientRect();t+=e.left,t+=e.right-e.width}for(let n=0;n<U.length;n++){let i=U[n]?.dim+K;if(e-i<t&&e-i-t<i){O=!1;break}}}if(!function(){let e;if(!x)return;eE();let t=ed(),n=ec(!1),i=Q("slidesPerPage");i="auto"===i?1/0:parseFloat(i+""),W=[];let r=0,o=0;for(let e of U)(!W.length||r+e.dim-t>.05||o>=i)&&(W.push({index:W.length,slides:[],dim:0,offset:0,pos:0}),r=0,o=0),W[W.length-1]?.slides.push(e),r+=e.dim+K,o++;let l=Q("center"),s=Q("fill"),u=0;for(let e of W){for(let t of(e.dim=(e.slides.length-1)*K,e.slides))e.dim+=t.dim;e.offset=u,e.pos=u,!1!==l&&(e.pos-=(t-e.dim)*.5),s&&!O&&n>t&&(e.pos=a(0,e.pos,n-t)),u+=e.dim+K}let f=[];for(let t of W){let n={...t};e&&.1>Math.abs(n.pos-e.pos)?(e.dim+=n.dim,e.slides=[...e.slides,...n.slides]):(e=n,n.index=f.length,f.push(n))}W=f,ea()}(),H=W[0]?.pos||0,_=W[W.length-1]?.pos||0,y===k.Init){E=void 0,I=Q("initialPage");let e=Q("initialSlide")||void 0;void 0!==e&&(I=eD.getPageIndex(e)||0),I=a(0,I,W.length-1),j=D=W[I]?.pos||0}else{let e=m?.isRunning()?m.getEndValues().pos:D;(e<H||e>_)&&(I=a(0,I,W.length-1),j=W[I||0]?.pos||0)}en("refresh")}function ey(e){if(!e||!i(e))return;let t=parseInt(e.getAttribute("index")||"-1"),n="";for(let t of Array.from(e.classList)){let e=t.match(/^f-(\w+)(Out|In)$/);e&&e[1]&&(n=e[1]+"")}if(!e||!n)return;let r=[`f-${n}Out`,`f-${n}In`,"to-prev","to-next","from-prev","from-next"];e.removeEventListener("animationend",ew),c(e,r.join(" ")),X.delete(t)}function eM(){if(!T)return;let e=X.size;for(let e of U)ey(e.el);X.clear(),e&&eR()}function ew(e){"f-"===e.animationName.substring(0,2)&&(ey(e.target),!X.size&&(c(x,"in-transition"),!V&&.5>Math.abs(eD.getPosition(!0)-j)&&(V=!0,en("settle"))),eR())}function eL(e){if(e.defaultPrevented)return;let t=e.composedPath()[0];if(t.closest("[data-carousel-go-prev]")){N(e),eD.prev();return}if(t.closest("[data-carousel-go-next]")){N(e),eD.next();return}let n=t.closest("[data-carousel-go-to]");if(n){N(e),eD.goTo(parseFloat(n.dataset.carouselGoTo||"")||0);return}if(t.closest("[data-carousel-download]")){N(e);let t=W[I]?.slides[0];if(t&&(t.downloadSrc||"image"===t.type&&t.src)){let e=t.downloadFilename,n=document.createElement("a"),i=t.downloadSrc||t.src||"";n.href=i,n.target="_blank",n.download=e||i,n.click()}return}en("click",e)}function ex(e){let t=e.el;t&&t.querySelector(".f-spinner")?.remove()}function eT(e){let t=e.el;t&&(t.querySelector(".f-html.is-error")?.remove(),c(t,"has-error"))}function eS(e){e||(e=W[I]?.slides[0]);let t=e?.el;if(!t)return;let n=Q("formatCaption",e);void 0===n&&(n=e.caption),n=n||"";let i=Q("captionEl");if(i&&i instanceof HTMLElement){if(e.index!==I)return;if("string"==typeof n&&(i.innerHTML=ee(n+"")),n instanceof HTMLElement){if(n.parentElement===i)return;i.innerHTML="",n.parentElement&&(n=n.cloneNode(!0)),i.append(n)}return}if(!n)return;let r=e.captionEl||t.querySelector(".f-caption");!r&&n instanceof HTMLElement&&n.classList.contains("f-caption")&&(r=n),!r&&(d(r=document.createElement("div"),"f-caption"),"string"==typeof n?r.innerHTML=ee(n+""):n instanceof HTMLElement&&(n.parentElement&&(n=n.cloneNode(!0)),r.append(n)));let o=`f-caption-${q}_${e.index}`;r.setAttribute("id",o),r.dataset.selectable="true",d(t,"has-caption"),t.setAttribute("aria-labelledby",o),e.captionEl=r,t.insertAdjacentElement("beforeend",r)}function eO(e,t={}){let{transition:i,tween:r}={...{transition:w.transition,tween:w.tween},...t||{}};if(!x||!m)return;let o=W.length;if(!o||function(e,t){if(!x||!m||!t||"string"!=typeof t||"tween"===t||W[I]?.slides.length>1)return!1;let n=W.length,i=e>I?1:-1;e=O?(e%n+n)%n:a(0,e,n-1),R&&(i*=-1);let r=W[I]?.slides[0],o=r?.index,l=W[e]?.slides[0],s=l?.index,u=W[e]?.pos;if(void 0===s||void 0===o||o===s||D===u||Math.abs(ed()-(l?.dim||0))>1)return!1;V=!1,m.pause(),eM(),d(x,"in-transition"),D=j=u;let f=em(r),p=em(l);return es(),f&&(X.add(o),f.style.transform="",f.addEventListener("animationend",ew),c(f,w.classes.isSelected),f.inert=!1,d(f,`f-${t}Out to-${i>0?"next":"prev"}`)),p&&(X.add(s),p.style.transform="",p.addEventListener("animationend",ew),d(p,w.classes.isSelected),p.inert=!1,d(p,`f-${t}In from-${i>0?"prev":"next"}`)),eR(),!0}(e,i))return;e=O?(e%o+o)%o:a(0,e,o-1),j=W[e||0]?.pos||0;let l=m.isRunning()?m.getEndValues().pos:D;if(1>Math.abs(j-l)){D=j,I!==e&&(eS(),ea(),eu(),E=I,en("change",I=e,E)),eR(),V||(V=!0,en("settle"));return}if(m.pause(),eM(),O){let e=ec(),t=Math.floor((l-W[0]?.pos)/e),n=j+t*e,i=n-e;j=[n+e,n,i].reduce(function(e,t){return Math.abs(t-l)<Math.abs(e-l)?t:e})}if(!1!==i&&n(r))return void m.spring(s({},w.tween,r)).from({pos:D}).to({pos:j}).start();D=j,es(),eR(),V||(V=!0,en("settle"))}function eR(){let e;if(!x||!T)return;let t=W[I];Y=ep();let n=new Set,i=[];for(let r of U){if(r.isVirtual&&!X.has(r.index)&&0>Y.indexOf(r))continue;let o=em(r);if(!o)continue;i.push(r);let l=t?.slides?.indexOf(r)>-1;if(l&&n.add(o),Q("adaptiveHeight")&&l){let t=(o.firstElementChild||o).getBoundingClientRect().height;e=void 0==e?t:Math.max(e,t)}}T&&e&&(T.style.height=`${e}px`),[...l(T,`.${w.classes.slide}`)].forEach(e=>{let t=G[parseInt(e.getAttribute("index")||"-1")];t||e.remove();let i=n.has(e);if(p(e,w.classes.isSelected,i),e.inert=0>Y.indexOf(t),t.isVirtual&&!X.has(t.index)&&0>Y.indexOf(t))return void ev(t);let r=t.pos?Math.round(1e4*t.pos)/1e4:0,o=0,l=0,s=0,a=0,f=w.setTransform||void 0;X.has(t.index)||(o=P?0:R?-1*r:r,l=P?r:0,s=u(o,0,t.dim,0,100),a=u(l,0,t.dim,0,100)),f instanceof Function&&!X.has(t.index)?f(eD,t,{x:o,y:l,xPercent:s,yPercent:a}):e.style.transform=o||l?`translate3d(${s}%, ${a}%,0)`:""}),en("render",i)}function eA(){for(let e of(x?.removeEventListener("click",eL),eM(),document.removeEventListener("mousemove",er),v?.disconnect(),v=void 0,G))e.el&&i(e.el)&&(e.state=void 0,ex(e),eT(e),ev(e),e.isVirtual?(e.el?.remove(),e.el=void 0):(e.el.style.transform="",T?.appendChild(e.el)));for(let e of Object.values(L))e?.destroy();for(let[e,t]of(L={},h?.destroy(),h=void 0,m?.destroy(),m=void 0,Object.entries(w.classes||{})))"container"!==e&&c(x,t);c(T,"is-draggable")}function eP(){return O||I>0}function eC(){return O||I<W.length-1}let eD={add:function(e,t){let n=D,i=I,r=ec(),o=Math.floor(((m?.isRunning()?m.getEndValues().pos:D)-W[0]?.pos)/r);for(let n of eg(e,t))en("addSlide",n);return el(F),eb(),m&&(i===I&&(n-=o*r),n===(j=W[I||0]?.pos||0)?D=j:m.spring({clamp:!0,mass:1,tension:300,friction:25,restDelta:1,restSpeed:1}).from({pos:n}).to({pos:j}).start()),eR(),eD},canGoPrev:eP,canGoNext:eC,destroy:function(){return en("destroy"),window.removeEventListener("resize",ei),eA(),et.clear(),x=null,W=[],G=[],w={...$},L={},U=[],b="",F="*",y=k.Destroyed,eD},emit:en,filter:function(e="*"){return el(e),eb(),eR(),en("filter",e),eD},getContainer:function(){return x},getGapDim:function(){return K},getGestures:function(){return h},getLastMouseMove:function(){return t},getOption:function(e){return Q(e)},getOptions:function(){return w},getPage:function(){return W[I]},getPageIndex:function(e){if(void 0!==e){for(let t of W||[])for(let n of t.slides)if(n.index===e)return t.index;return -1}return I},getPageProgress:function(e,t){void 0===e&&(e=I);let n=W[e];if(!n)return e>I?-1:1;let i=ec(),r=K,o=n.pos,l=eD.getPosition();if(O&&!0!==t){let e=Math.floor((l-W[0]?.pos)/i);l-=e*i,o=[o+i,o,o-i].reduce(function(e,t){return Math.abs(t-l)<Math.abs(e-l)?t:e})}return(l-o)/(n.dim+r)},getPageVisibility:function(e){void 0===e&&(e=I);let t=W[e];if(!t)return e>I?-1:1;let n=eD.getPosition(),i=ed(),r=t.pos;if(O){let e=eD.getPosition(),t=ec(),n=r+Math.floor((e-W[0]?.pos)/t)*t,i=n-t;r=[n+t,n,i].reduce(function(t,n){return Math.abs(n-e)<Math.abs(t-e)?n:t})}return r>n&&r+t.dim<n+i?1:r<n?(r+t.dim-n)/t.dim:r+t.dim>n+i?(n+i-r)/t.dim:0},getPages:function(){return W},getPlugins:function(){return L},getPosition:function(e){let t=D;if(O&&!0!==e){let e=ec();t-=Math.floor((D-W[0]?.pos||0)/e)*e}return t},getSlides:function(){return G},getState:function(){return y},getTotalSlideDim:ec,getTween:function(){return m},getViewport:function(){return T},getViewportDim:ed,getVisibleSlides:function(e){return void 0===e?Y:ep(e)},goTo:eO,hasNavigated:function(){return void 0!==E},hideError:eT,hideLoading:ex,init:function(){if(!e||!i(e))throw Error("No Element found");return y!==k.Init&&(eA(),y=k.Init),x=e,M=r,window.removeEventListener("resize",ei),M.breakpoints&&window.addEventListener("resize",ei),ei(),eD},isInfinite:function(){return O},isInTransition:function(){return X.size>0},isRTL:function(){return R},isSettled:function(){return V},isVertical:function(){return P},localize:function(e,t=[]){return ee(e,t)},next:function(e={}){return eO(I+1,e),eD},off:function(e,t){for(let n of e instanceof Array?e:[e])et.has(n)&&et.set(n,et.get(n).filter(e=>e!==t));return eD},on:function(e,t){for(let n of e instanceof Array?e:[e])et.set(n,[...et.get(n)||[],t]);return eD},prev:function(e={}){return eO(I-1,e),eD},remove:function(e){void 0===e&&(e=G.length-1);let t=G[e];return t&&(en("removeSlide",t),t.el&&(ey(t.el),t.el.remove(),t.el=void 0),G.splice(e,1),el(F),eb(),eR()),eD},setPosition:function(e){D=e,es(),eR()},showError:function(e,t){ex(e),eT(e);let n=e.el;if(n){let i=document.createElement("div");d(i,"f-html"),d(i,"is-error"),i.innerHTML=ee(t||"<p>{{ERROR}}</p>"),e.htmlEl=i,d(n,"has-html"),d(n,"has-error"),n.insertAdjacentElement("afterbegin",i),en("contentReady",e)}return eD},showLoading:function(e){let t=e.el,n=t?.querySelector(".f-spinner");if(!t||n)return eD;let i=f(Q("spinnerTpl"));return i&&(d(i,"f-spinner"),t.insertAdjacentElement("beforeend",i)),eD},version:"6.0.29"};return eD};B.l10n={en_EN:F},B.getDefaults=()=>$,e.Carousel=B,e.CarouselSlideContentState=G,e.CarouselState=k});