@ussebastian/kitdigital
Version:
Kit Digital de la Universidad San Sebastián
3 lines (2 loc) • 17.5 kB
JavaScript
System.register([],(function(n){"use strict";return{execute:function(){function t(n){return"number"==typeof n}function e(n){return"string"==typeof n}function r(n){return"boolean"==typeof n}function o(n){return"[object Object]"===Object.prototype.toString.call(n)}function i(n){return Math.abs(n)}function c(n){return Math.sign(n)}function u(n,t){return i(n-t)}function s(n){return p(n).map(Number)}function a(n){return n[d(n)]}function d(n){return Math.max(0,n.length-1)}function l(n,t){return t===d(n)}function f(n,t=0){return Array.from(Array(n),((n,e)=>t+e))}function p(n){return Object.keys(n)}function m(n,t){return[n,t].reduce(((n,t)=>(p(t).forEach((e=>{const r=n[e],i=t[e],c=o(r)&&o(i);n[e]=c?m(r,i):i})),n)),{})}function g(n,t){return void 0!==t.MouseEvent&&n instanceof t.MouseEvent}function h(){let n=[];const t={add:function(e,r,o,i={passive:!0}){let c;if("addEventListener"in e)e.addEventListener(r,o,i),c=()=>e.removeEventListener(r,o,i);else{const n=e;n.addListener(o),c=()=>n.removeListener(o)}return n.push(c),t},clear:function(){n=n.filter((n=>n()))}};return t}function x(n,t,e,r){const o=h(),c=1e3/60;let u=null,s=0,a=0;function d(n){if(!a)return;u||(u=n);const o=n-u;for(u=n,s+=o;s>=c;)e(),s-=c;const l=i(s/c);r(l),a&&t.requestAnimationFrame(d)}function l(){t.cancelAnimationFrame(a),u=null,s=0,a=0}return{init:function(){o.add(n,"visibilitychange",(()=>{n.hidden&&(u=null,s=0)}))},destroy:function(){l(),o.clear()},start:function(){a||(a=t.requestAnimationFrame(d))},stop:l,update:e,render:r}}function y(n=0,t=0){const e=i(n-t);function r(t){return t<n}function o(n){return n>t}function c(n){return r(n)||o(n)}return{length:e,max:t,min:n,constrain:function(e){return c(e)?r(e)?n:t:e},reachedAny:c,reachedMax:o,reachedMin:r,removeOffset:function(n){return e?n-e*Math.ceil((n-t)/e):n}}}function v(n,t,e){const{constrain:r}=y(0,n),o=n+1;let c=u(t);function u(n){return e?i((o+n)%o):r(n)}function s(){return c}function a(){return v(n,s(),e)}const d={get:s,set:function(n){return c=u(n),d},add:function(n){return a().set(s()+n)},clone:a};return d}function S(n,t,e,o,s,a,d,l,f,p,m,x,v,S,b,w,E,L,D){const{cross:I,direction:A}=n,M=["INPUT","SELECT","TEXTAREA"],O={passive:!1},T=h(),F=h(),P=y(50,225).constrain(S.measure(20)),z={mouse:300,touch:400},H={mouse:500,touch:600},k=b?43:25;let V=!1,B=0,N=0,R=!1,C=!1,j=!1,G=!1;function q(n){if(!g(n,o)&&n.touches.length>=2)return U(n);const t=a.readPoint(n),e=a.readPoint(n,I),r=u(t,B),i=u(e,N);if(!C&&!G){if(!n.cancelable)return U(n);if(C=r>i,!C)return U(n)}const c=a.pointerMove(n);r>w&&(j=!0),p.useFriction(.3).useDuration(.75),l.start(),s.add(A(c)),n.preventDefault()}function U(n){const t=m.byDistance(0,!1).index!==x.get(),e=a.pointerUp(n)*(b?H:z)[G?"mouse":"touch"],r=function(n,t){const e=x.add(-1*c(n)),r=m.byDistance(n,!b).distance;return b||i(n)<P?r:E&&t?.5*r:m.byIndex(e.get(),0).distance}(A(e),t),o=function(n,t){if(0===n||0===t)return 0;if(i(n)<=i(t))return 0;const e=u(i(n),i(t));return i(e/n)}(e,r),s=k-10*o,d=L+o/50;C=!1,R=!1,F.clear(),p.useDuration(s).useFriction(d),f.distance(r,!b),G=!1,v.emit("pointerUp")}function W(n){j&&(n.stopPropagation(),n.preventDefault(),j=!1)}return{init:function(n){if(!D)return;function i(i){(r(D)||D(n,i))&&function(n){const r=g(n,o);if(G=r,j=b&&r&&!n.buttons&&V,V=u(s.get(),d.get())>=2,r&&0!==n.button)return;if(function(n){const t=n.nodeName||"";return M.includes(t)}(n.target))return;R=!0,a.pointerDown(n),p.useFriction(0).useDuration(0),s.set(d),function(){const n=G?e:t;F.add(n,"touchmove",q,O).add(n,"touchend",U).add(n,"mousemove",q,O).add(n,"mouseup",U)}(),B=a.readPoint(n),N=a.readPoint(n,I),v.emit("pointerDown")}(i)}const c=t;T.add(c,"dragstart",(n=>n.preventDefault()),O).add(c,"touchmove",(()=>{}),O).add(c,"touchend",(()=>{})).add(c,"touchstart",i).add(c,"mousedown",i).add(c,"touchcancel",U).add(c,"contextmenu",U).add(c,"click",W,!0)},destroy:function(){T.clear(),F.clear()},pointerDown:function(){return R}}}function b(n,t){let e,r;function o(n){return n.timeStamp}function c(e,r){const o="client"+("x"===(r||n.scroll)?"X":"Y");return(g(e,t)?e:e.touches[0])[o]}return{pointerDown:function(n){return e=n,r=n,c(n)},pointerMove:function(n){const t=c(n)-c(r),i=o(n)-o(e)>170;return r=n,i&&(e=n),t},pointerUp:function(n){if(!e||!r)return 0;const t=c(r)-c(e),u=o(n)-o(e),s=o(n)-o(r)>170,a=t/u;return u&&!s&&i(a)>.1?a:0},readPoint:c}}function w(n,t,e,o,c,u,s){let a,d,l=[],f=!1;function p(n){return c.measureSize(s.measure(n))}return{init:function(c){if(!u)return;d=p(n),l=o.map(p),a=new ResizeObserver((s=>{f||(r(u)||u(c,s))&&function(r){for(const u of r){const r=u.target===n,s=o.indexOf(u.target),a=r?d:l[s];if(i(p(r?n:o[s])-a)>=.5){e.requestAnimationFrame((()=>{c.reInit(),t.emit("resize")}));break}}}(s)})),[n].concat(o).forEach((n=>a.observe(n)))},destroy:function(){a&&a.disconnect(),f=!0}}}function E(n,t,e,r,o){const c=o.measure(10),u=o.measure(50),s=y(.1,.99);let a=!1;return{constrain:function(o){if(a||!n.reachedAny(e.get())||!n.reachedAny(t.get()))return;const d=n.reachedMin(t.get())?"min":"max",l=i(n[d]-t.get()),f=e.get()-t.get(),p=s.constrain(l/u);e.subtract(f*p),!o&&i(f)<c&&(e.set(n.constrain(e.get())),r.useDuration(25).useBaseFriction())},toggleActive:function(n){a=!n}}}function L(n,t,e,r){const o=t.min+.1,i=t.max+.1,{reachedMin:c,reachedMax:u}=y(o,i);return{loop:function(t){if(!function(n){return 1===n?u(e.get()):-1===n&&c(e.get())}(t))return;const o=n*(-1*t);r.forEach((n=>n.add(o)))}}}function D(n,t,e,r,o){const{reachedAny:u,removeOffset:s,constrain:d}=r;function l(n){return n.concat().sort(((n,t)=>i(n)-i(t)))[0]}function f(t,r){const o=[t,t+e,t-e];if(!n)return t;if(!r)return l(o);const i=o.filter((n=>c(n)===r));return i.length?l(i):a(o)-e}return{byDistance:function(e,r){const c=o.get()+e,{index:a,distance:l}=function(e){const r=n?s(e):d(e),o=t.map(((n,t)=>({diff:f(n-r,0),index:t}))).sort(((n,t)=>i(n.diff)-i(t.diff))),{index:c}=o[0];return{index:c,distance:r}}(c),p=!n&&u(c);return!r||p?{index:a,distance:e}:{index:a,distance:e+f(t[a]-l,0)}},byIndex:function(n,e){return{index:n,distance:f(t[n]-o.get(),e)}},shortcut:f}}function I(n){let e=n;function r(n){return t(n)?n:n.get()}return{get:function(){return e},set:function(n){e=r(n)},add:function(n){e+=r(n)},subtract:function(n){e-=r(n)}}}function A(n,t){const e="x"===n.scroll?function(n){return`translate3d(${n}px,0px,0px)`}:function(n){return`translate3d(0px,${n}px,0px)`},r=t.style;let o=!1;return{clear:function(){o||(r.transform="",t.getAttribute("style")||t.removeAttribute("style"))},to:function(t){o||(r.transform=e(n.direction(t)))},toggleActive:function(n){o=!n}}}function M(n,t,e,r,o,i,c,u,a){const d=.5,l=s(o),f=s(o).reverse(),p=function(){const n=c[0];return h(g(f,n),e,!1)}().concat(function(){const n=t-c[0]-1;return h(g(l,n),-e,!0)}());function m(n,t){return n.reduce(((n,t)=>n-o[t]),t)}function g(n,t){return n.reduce(((n,e)=>m(n,t)>0?n.concat([e]):n),[])}function h(o,c,s){const l=function(n){return i.map(((e,o)=>({start:e-r[o]+d+n,end:e+t-d+n})))}(c);return o.map((t=>{const r=s?0:-e,o=s?e:0,i=s?"end":"start",c=l[t][i];return{index:t,loopPoint:c,slideLocation:I(-1),translate:A(n,a[t]),target:()=>u.get()>c?r:o}}))}return{canLoop:function(){return p.every((({index:n})=>m(l.filter((t=>t!==n)),t)<=.1))},clear:function(){p.forEach((n=>n.translate.clear()))},loop:function(){p.forEach((n=>{const{target:t,translate:e,slideLocation:r}=n,o=t();o!==r.get()&&(e.to(o),r.set(o))}))},loopPoints:p}}function O(n,t,e){let o,i=!1;return{init:function(c){e&&(o=new MutationObserver((n=>{i||(r(e)||e(c,n))&&function(n){for(const e of n)if("childList"===e.type){c.reInit(),t.emit("slidesChanged");break}}(n)})),o.observe(n,{childList:!0}))},destroy:function(){o&&o.disconnect(),i=!0}}}function T(n,t,e,r){const o={};let i,c=null,u=null,s=!1;return{init:function(){i=new IntersectionObserver((n=>{s||(n.forEach((n=>{const e=t.indexOf(n.target);o[e]=n})),c=null,u=null,e.emit("slidesInView"))}),{root:n.parentElement,threshold:r}),t.forEach((n=>i.observe(n)))},destroy:function(){i&&i.disconnect(),s=!0},get:function(n=!0){if(n&&c)return c;if(!n&&u)return u;const t=function(n){return p(o).reduce(((t,e)=>{const r=parseInt(e),{isIntersecting:i}=o[r];return(n&&i||!n&&!i)&&t.push(r),t}),[])}(n);return n&&(c=t),n||(u=t),t}}}function F(n,e,r,o,c,u,l,f,p){const{startEdge:m,endEdge:g,direction:h}=n,x=t(r);return{groupSlides:function(n){return x?function(n,t){return s(n).filter((n=>n%t==0)).map((e=>n.slice(e,e+t)))}(n,r):function(n){return n.length?s(n).reduce(((t,r,s)=>{const x=a(t)||0,y=0===x,v=r===d(n),S=c[m]-u[x][m],b=c[m]-u[r][g],w=!o&&y?h(l):0,E=i(b-(!o&&v?h(f):0)-(S+w));return s&&E>e+p&&t.push(r),v&&t.push(n.length),t}),[]).map(((t,e,r)=>{const o=Math.max(r[e-1]||0);return n.slice(o,t)})):[]}(n)}}}function P(n,r,o,p,m,g,P){const{align:z,axis:H,direction:k,startIndex:V,loop:B,duration:N,dragFree:R,dragThreshold:C,inViewThreshold:j,slidesToScroll:G,skipSnaps:q,containScroll:U,watchResize:W,watchSlides:$,watchDrag:Q}=g,X={measure:function(n){const{offsetTop:t,offsetLeft:e,offsetWidth:r,offsetHeight:o}=n;return{top:t,right:e+r,bottom:t+o,left:e,width:r,height:o}}},Y=X.measure(r),J=o.map(X.measure),K=function(n,t){const e="rtl"===t,r="y"===n,o=!r&&e?-1:1;return{scroll:r?"y":"x",cross:r?"x":"y",startEdge:r?"top":e?"right":"left",endEdge:r?"bottom":e?"left":"right",measureSize:function(n){const{height:t,width:e}=n;return r?t:e},direction:function(n){return n*o}}}(H,k),Z=K.measureSize(Y),_=function(n){return{measure:function(t){return n*(t/100)}}}(Z),nn=function(n,t){const r={start:function(){return 0},center:function(n){return o(n)/2},end:o};function o(n){return t-n}return{measure:function(o,i){return e(n)?r[n](o):n(t,o,i)}}}(z,Z),tn=!B&&!!U,en=B||!!U,{slideSizes:rn,slideSizesWithGaps:on,startGap:cn,endGap:un}=function(n,t,e,r,o,c){const{measureSize:u,startEdge:s,endEdge:d}=n,f=e[0]&&o,p=function(){if(!f)return 0;const n=e[0];return i(t[s]-n[s])}(),m=function(){if(!f)return 0;const n=c.getComputedStyle(a(r));return parseFloat(n.getPropertyValue(`margin-${d}`))}(),g=e.map(u),h=e.map(((n,t,e)=>{const r=!t,o=l(e,t);return r?g[t]+p:o?g[t]+m:e[t+1][s]-n[s]})).map(i);return{slideSizes:g,slideSizesWithGaps:h,startGap:p,endGap:m}}(K,Y,J,o,en,m),sn=F(K,Z,G,B,Y,J,cn,un,2),{snaps:an,snapsAligned:dn}=function(n,t,e,r,o){const{startEdge:c,endEdge:u}=n,{groupSlides:s}=o,d=s(r).map((n=>a(n)[u]-n[0][c])).map(i).map(t.measure),l=r.map((n=>e[c]-n[c])).map((n=>-i(n))),f=s(l).map((n=>n[0])).map(((n,t)=>n+d[t]));return{snaps:l,snapsAligned:f}}(K,nn,Y,J,sn),ln=-a(an)+a(on),{snapsContained:fn,scrollContainLimit:pn}=function(n,t,e,r,o){const i=y(-t+n,0),c=e.map(((n,t)=>{const{min:r,max:o}=i,c=i.constrain(n),u=!t,s=l(e,t);return u?o:s||d(r,c)?r:d(o,c)?o:c})).map((n=>parseFloat(n.toFixed(3)))),s=function(){const n=c[0],t=a(c);return y(c.lastIndexOf(n),c.indexOf(t)+1)}();function d(n,t){return u(n,t)<1}return{snapsContained:function(){if(t<=n+o)return[i.max];if("keepSnaps"===r)return c;const{min:e,max:u}=s;return c.slice(e,u)}(),scrollContainLimit:s}}(Z,ln,dn,U,2),mn=tn?fn:dn,{limit:gn}=function(n,t,e){const r=t[0];return{limit:y(e?r-n:a(t),r)}}(ln,mn,B),hn=v(d(mn),V,B),xn=hn.clone(),yn=s(o),vn=x(p,m,(()=>(({dragHandler:n,scrollBody:t,scrollBounds:e,options:{loop:r}})=>{r||e.constrain(n.pointerDown()),t.seek()})(Pn)),(n=>(({scrollBody:n,translate:t,location:e,offsetLocation:r,scrollLooper:o,slideLooper:i,dragHandler:c,animation:u,eventHandler:s,options:{loop:a}},d)=>{const l=n.velocity(),f=n.settled();f&&!c.pointerDown()&&(u.stop(),s.emit("settle")),f||s.emit("scroll"),r.set(e.get()-l+l*d),a&&(o.loop(n.direction()),i.loop()),t.to(r.get())})(Pn,n))),Sn=mn[hn.get()],bn=I(Sn),wn=I(Sn),En=I(Sn),Ln=function(n,t,e,r,o){let u=0,s=0,a=r,d=o,l=n.get(),f=0;function p(n){return a=n,g}function m(n){return d=n,g}const g={direction:function(){return s},duration:function(){return a},velocity:function(){return u},seek:function(){const t=e.get()-n.get();let r=0;return a?(u+=t/a,u*=d,l+=u,n.add(u),r=l-f):(u=0,n.set(e),r=t),s=c(r),f=l,g},settled:function(){return i(e.get()-t.get())<.001},useBaseFriction:function(){return m(o)},useBaseDuration:function(){return p(r)},useFriction:m,useDuration:p};return g}(bn,wn,En,N,.68),Dn=D(B,mn,ln,gn,En),In=function(n,t,e,r,o,i,c){function u(o){const u=o.distance,s=o.index!==t.get();i.add(u),u&&(r.duration()?n.start():(n.update(),n.render(1),n.update())),s&&(e.set(t.get()),t.set(o.index),c.emit("select"))}return{distance:function(n,t){u(o.byDistance(n,t))},index:function(n,e){const r=t.clone().set(n);u(o.byIndex(r.get(),e))}}}(vn,hn,xn,Ln,Dn,En,P),An=function(n){const{max:t,length:e}=n;return{get:function(n){return e?(n-t)/-e:0}}}(gn),Mn=h(),On=T(r,o,P,j),{slideRegistry:Tn}=function(n,t,e,r,o,i){const{groupSlides:c}=o,{min:u,max:s}=r;return{slideRegistry:function(){const r=c(i),o=!n||"keepSnaps"===t;return 1===e.length?[i]:o?r:r.slice(u,s).map(((n,t,e)=>{const r=!t,o=l(e,t);return r?f(a(e[0])+1):o?f(d(i)-a(e)[0]+1,a(e)[0]):n}))}()}}(tn,U,mn,pn,sn,yn),Fn=function(n,e,r,o,i,c,u){let s=0;function a(n){"Tab"===n.code&&(s=(new Date).getTime())}function d(a){c.add(a,"focus",(()=>{if((new Date).getTime()-s>10)return;n.scrollLeft=0;const c=e.indexOf(a),d=r.findIndex((n=>n.includes(c)));t(d)&&(i.useDuration(0),o.index(d,0),u.emit("slideFocus"))}),{passive:!0,capture:!0})}return{init:function(){c.add(document,"keydown",a,!1),e.forEach(d)}}}(n,o,Tn,In,Ln,Mn,P),Pn={ownerDocument:p,ownerWindow:m,eventHandler:P,containerRect:Y,slideRects:J,animation:vn,axis:K,dragHandler:S(K,n,p,m,En,b(K,m),bn,vn,In,Ln,Dn,hn,P,_,R,C,q,.68,Q),eventStore:Mn,percentOfView:_,index:hn,indexPrevious:xn,limit:gn,location:bn,offsetLocation:wn,options:g,resizeHandler:w(r,P,m,o,K,W,X),scrollBody:Ln,scrollBounds:E(gn,wn,En,Ln,_),scrollLooper:L(ln,gn,wn,[bn,wn,En]),scrollProgress:An,scrollSnapList:mn.map(An.get),scrollSnaps:mn,scrollTarget:Dn,scrollTo:In,slideLooper:M(K,Z,ln,rn,on,an,mn,wn,o),slideFocus:Fn,slidesHandler:O(r,P,$),slidesInView:On,slideIndexes:yn,slideRegistry:Tn,slidesToScroll:sn,target:En,translate:A(K,r)};return Pn}n("E",k);const z={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0};function H(n){function t(n,t){return m(n,t||{})}const e={mergeOptions:t,optionsAtMedia:function(e){const r=e.breakpoints||{},o=p(r).filter((t=>n.matchMedia(t).matches)).map((n=>r[n])).reduce(((n,e)=>t(n,e)),{});return t(e,o)},optionsMediaQueries:function(t){return t.map((n=>p(n.breakpoints||{}))).reduce(((n,t)=>n.concat(t)),[]).map(n.matchMedia)}};return e}function k(n,t,r){const o=n.ownerDocument,i=o.defaultView,c=H(i),u=function(n){let t=[];return{init:function(e,r){return t=r.filter((({options:t})=>!1!==n.optionsAtMedia(t).active)),t.forEach((t=>t.init(e,n))),r.reduce(((n,t)=>Object.assign(n,{[t.name]:t})),{})},destroy:function(){t=t.filter((n=>n.destroy()))}}}(c),s=h(),a=function(){let n,t={};function e(n){return t[n]||[]}const r={init:function(t){n=t},emit:function(t){return e(t).forEach((e=>e(n,t))),r},off:function(n,o){return t[n]=e(n).filter((n=>n!==o)),r},on:function(n,o){return t[n]=e(n).concat([o]),r},clear:function(){t={}}};return r}(),{mergeOptions:d,optionsAtMedia:l,optionsMediaQueries:f}=c,{on:p,off:m,emit:g}=a,x=M;let y,v,S,b,w=!1,E=d(z,k.globalOptions),L=d(E),D=[];function I(t){const e=P(n,S,b,o,i,t,a);if(t.loop&&!e.slideLooper.canLoop()){return I(Object.assign({},t,{loop:!1}))}return e}function A(t,r){w||(E=d(E,t),L=l(E),D=r||D,function(){const{container:t,slides:r}=L,o=e(t)?n.querySelector(t):t;S=o||n.children[0];const i=e(r)?S.querySelectorAll(r):r;b=[].slice.call(i||S.children)}(),y=I(L),f([E,...D.map((({options:n})=>n))]).forEach((n=>s.add(n,"change",M))),L.active&&(y.translate.to(y.location.get()),y.animation.init(),y.slidesInView.init(),y.slideFocus.init(),y.eventHandler.init(V),y.resizeHandler.init(V),y.slidesHandler.init(V),y.options.loop&&y.slideLooper.loop(),S.offsetParent&&b.length&&y.dragHandler.init(V),v=u.init(V,D)))}function M(n,t){const e=F();O(),A(d({startIndex:e},n),t),a.emit("reInit")}function O(){y.dragHandler.destroy(),y.eventStore.clear(),y.translate.clear(),y.slideLooper.clear(),y.resizeHandler.destroy(),y.slidesHandler.destroy(),y.slidesInView.destroy(),y.animation.destroy(),u.destroy(),s.clear()}function T(n,t,e){L.active&&!w&&(y.scrollBody.useBaseFriction().useDuration(!0===t?0:L.duration),y.scrollTo.index(n,e||0))}function F(){return y.index.get()}const V={canScrollNext:function(){return y.index.add(1).get()!==F()},canScrollPrev:function(){return y.index.add(-1).get()!==F()},containerNode:function(){return S},internalEngine:function(){return y},destroy:function(){w||(w=!0,s.clear(),O(),a.emit("destroy"),a.clear())},off:m,on:p,emit:g,plugins:function(){return v},previousScrollSnap:function(){return y.indexPrevious.get()},reInit:x,rootNode:function(){return n},scrollNext:function(n){T(y.index.add(1).get(),n,-1)},scrollPrev:function(n){T(y.index.add(-1).get(),n,1)},scrollProgress:function(){return y.scrollProgress.get(y.location.get())},scrollSnapList:function(){return y.scrollSnapList},scrollTo:T,selectedScrollSnap:F,slideNodes:function(){return b},slidesInView:function(){return y.slidesInView.get()},slidesNotInView:function(){return y.slidesInView.get(!1)}};return A(t,r),setTimeout((()=>a.emit("init")),0),V}k.globalOptions=void 0}}}));
//# sourceMappingURL=embla-carousel.esm-0aabc2f2.js.map