UNPKG

@fancyapps/ui

Version:

Robust JavaScript UI Component Library

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