Your IP : 216.73.216.123


Current Path : /home/smartbloks/.trash/_astro.1/
Upload File :
Current File : /home/smartbloks/.trash/_astro.1/carousel.BG3v4Is5.js

import{d as Q,r as s,m as M,B as w,o as ye,C as xe,D as Ae,c as O,w as J,E as fe,G as y,H as h,F as Te}from"./runtime-core.esm-bundler.EZcGeBMH.js";/**
 * Vue 3 Carousel 0.3.3
 * (c) 2024
 * @license MIT
 */const v={itemsToShow:1,itemsToScroll:1,modelValue:0,transition:300,autoplay:0,snapAlign:"center",wrapAround:!1,throttle:16,pauseAutoplayOnHover:!1,mouseDrag:!0,touchDrag:!0,dir:"ltr",breakpoints:void 0,i18n:{ariaNextSlide:"Navigate to next slide",ariaPreviousSlide:"Navigate to previous slide",ariaNavigateToSlide:"Navigate to slide {slideNumber}",ariaGallery:"Gallery",itemXofY:"Item {currentSlide} of {slidesCount}",iconArrowUp:"Arrow pointing upwards",iconArrowDown:"Arrow pointing downwards",iconArrowRight:"Arrow pointing to the right",iconArrowLeft:"Arrow pointing to the left"}},me={itemsToShow:{default:v.itemsToShow,type:Number},itemsToScroll:{default:v.itemsToScroll,type:Number},wrapAround:{default:v.wrapAround,type:Boolean},throttle:{default:v.throttle,type:Number},snapAlign:{default:v.snapAlign,validator(e){return["start","end","center","center-even","center-odd"].includes(e)}},transition:{default:v.transition,type:Number},breakpoints:{default:v.breakpoints,type:Object},autoplay:{default:v.autoplay,type:Number},pauseAutoplayOnHover:{default:v.pauseAutoplayOnHover,type:Boolean},modelValue:{default:void 0,type:Number},mouseDrag:{default:v.mouseDrag,type:Boolean},touchDrag:{default:v.touchDrag,type:Boolean},dir:{default:v.dir,validator(e){return["rtl","ltr"].includes(e)}},i18n:{default:v.i18n,type:Object},settings:{default(){return{}},type:Object}};function _e({config:e,slidesCount:a}){const{snapAlign:n,wrapAround:o,itemsToShow:l=1}=e;if(o)return Math.max(a-1,0);let r;switch(n){case"start":r=a-l;break;case"end":r=a-1;break;case"center":case"center-odd":r=a-Math.ceil((l-.5)/2);break;case"center-even":r=a-Math.ceil(l/2);break;default:r=0;break}return Math.max(r,0)}function ke({config:e,slidesCount:a}){const{wrapAround:n,snapAlign:o,itemsToShow:l=1}=e;let r=0;if(n||l>a)return r;switch(o){case"start":r=0;break;case"end":r=l-1;break;case"center":case"center-odd":r=Math.floor((l-1)/2);break;case"center-even":r=Math.floor((l-2)/2);break;default:r=0;break}return r}function K({val:e,max:a,min:n}){return a<n?e:Math.min(Math.max(e,n),a)}function Ce({config:e,currentSlide:a,slidesCount:n}){const{snapAlign:o,wrapAround:l,itemsToShow:r=1}=e;let g=a;switch(o){case"center":case"center-odd":g-=(r-1)/2;break;case"center-even":g-=(r-2)/2;break;case"end":g-=r-1;break}return l?g:K({val:g,max:n-r,min:0})}function pe(e){return e?e.reduce((a,n)=>{var o;return n.type===Te?[...a,...pe(n.children)]:((o=n.type)===null||o===void 0?void 0:o.name)==="CarouselSlide"?[...a,n]:a},[]):[]}function B({val:e,max:a,min:n=0}){return e>a?B({val:e-(a+1),max:a,min:n}):e<n?B({val:e+(a+1),max:a,min:n}):e}function Oe(e,a){let n;return a?function(...o){const l=this;n||(e.apply(l,o),n=!0,setTimeout(()=>n=!1,a))}:e}function Me(e,a){let n;return function(...o){n&&clearTimeout(n),n=setTimeout(()=>{e(...o),n=null},a)}}function he(e="",a={}){return Object.entries(a).reduce((n,[o,l])=>n.replace(`{${o}}`,String(l)),e)}var je=Q({name:"ARIA",setup(){const e=h("config",M(Object.assign({},v))),a=h("currentSlide",s(0)),n=h("slidesCount",s(0));return()=>y("div",{class:["carousel__liveregion","carousel__sr-only"],"aria-live":"polite","aria-atomic":"true"},he(e.i18n.itemXofY,{currentSlide:a.value+1,slidesCount:n.value}))}}),Ee=Q({name:"Carousel",props:me,setup(e,{slots:a,emit:n,expose:o}){var l;const r=s(null),g=s([]),c=s(0),f=s(0),i=M(Object.assign({},v));let S=Object.assign({},v),x;const d=s((l=e.modelValue)!==null&&l!==void 0?l:0),X=s(0),Z=s(0),k=s(0),j=s(0);let C,$;w("config",i),w("slidesCount",f),w("currentSlide",d),w("maxSlide",k),w("minSlide",j),w("slideWidth",c);function Y(){x=Object.assign({},e.breakpoints),S=Object.assign(Object.assign(Object.assign({},S),e),{i18n:Object.assign(Object.assign({},S.i18n),e.i18n),breakpoints:void 0}),ee(S)}function D(){if(!x||!Object.keys(x).length)return;const t=Object.keys(x).map(u=>Number(u)).sort((u,b)=>+b-+u);let m=Object.assign({},S);t.some(u=>{const b=window.matchMedia(`(min-width: ${u}px)`).matches;return b&&(m=Object.assign(Object.assign({},m),x[u])),b}),ee(m)}function ee(t){Object.entries(t).forEach(([m,u])=>i[m]=u)}const te=Me(()=>{D(),I(),N()},16);function N(){if(!r.value)return;const t=r.value.getBoundingClientRect();c.value=t.width/i.itemsToShow}function I(){f.value<=0||(Z.value=Math.ceil((f.value-1)/2),k.value=_e({config:i,slidesCount:f.value}),j.value=ke({config:i,slidesCount:f.value}),i.wrapAround||(d.value=K({val:d.value,max:k.value,min:j.value})))}ye(()=>{xe(()=>N()),setTimeout(()=>N(),1e3),D(),re(),window.addEventListener("resize",te,{passive:!0}),n("init")}),Ae(()=>{$&&clearTimeout($),C&&clearInterval(C),window.removeEventListener("resize",te,{passive:!0})});let p=!1;const L={x:0,y:0},P={x:0,y:0},A=M({x:0,y:0}),V=s(!1),H=s(!1),Se=()=>{V.value=!0},be=()=>{V.value=!1};function ne(t){["INPUT","TEXTAREA","SELECT"].includes(t.target.tagName)||(p=t.type==="touchstart",p||t.preventDefault(),!(!p&&t.button!==0||T.value)&&(L.x=p?t.touches[0].clientX:t.clientX,L.y=p?t.touches[0].clientY:t.clientY,document.addEventListener(p?"touchmove":"mousemove",ae,!0),document.addEventListener(p?"touchend":"mouseup",ie,!0)))}const ae=Oe(t=>{H.value=!0,P.x=p?t.touches[0].clientX:t.clientX,P.y=p?t.touches[0].clientY:t.clientY;const m=P.x-L.x,u=P.y-L.y;A.y=u,A.x=m},i.throttle);function ie(){const t=i.dir==="rtl"?-1:1,m=Math.sign(A.x)*.4,u=Math.round(A.x/c.value+m)*t;if(u&&!p){const b=ve=>{window.removeEventListener("click",b,!0)};window.addEventListener("click",b,!0)}_(d.value-u),A.x=0,A.y=0,H.value=!1,document.removeEventListener(p?"touchmove":"mousemove",ae,!0),document.removeEventListener(p?"touchend":"mouseup",ie,!0)}function re(){!i.autoplay||i.autoplay<=0||(C=setInterval(()=>{i.pauseAutoplayOnHover&&V.value||R()},i.autoplay))}function oe(){C&&(clearInterval(C),C=null),re()}const T=s(!1);function _(t){const m=i.wrapAround?t:K({val:t,max:k.value,min:j.value});d.value===m||T.value||(n("slide-start",{slidingToIndex:t,currentSlideIndex:d.value,prevSlideIndex:X.value,slidesCount:f.value}),T.value=!0,X.value=d.value,d.value=m,$=setTimeout(()=>{if(i.wrapAround){const u=B({val:m,max:k.value,min:0});u!==d.value&&(d.value=u,n("loop",{currentSlideIndex:d.value,slidingToIndex:t}))}n("update:modelValue",d.value),n("slide-end",{currentSlideIndex:d.value,prevSlideIndex:X.value,slidesCount:f.value}),T.value=!1,oe()},i.transition))}function R(){_(d.value+i.itemsToScroll)}function U(){_(d.value-i.itemsToScroll)}const le={slideTo:_,next:R,prev:U};w("nav",le),w("isSliding",T);const se=O(()=>Ce({config:i,currentSlide:d.value,slidesCount:f.value}));w("slidesToScroll",se);const we=O(()=>{const t=i.dir==="rtl"?-1:1,m=se.value*c.value*t;return{transform:`translateX(${A.x-m}px)`,transition:`${T.value?i.transition:0}ms`,margin:i.wrapAround?`0 -${f.value*c.value}px`:"",width:"100%"}});function ue(){Y(),D(),I(),N(),oe()}Object.keys(me).forEach(t=>{["modelValue"].includes(t)||J(()=>e[t],ue)}),J(()=>e.modelValue,t=>{t!==d.value&&_(Number(t))}),J(f,I),n("before-init"),Y();const ce={config:i,slidesCount:f,slideWidth:c,next:R,prev:U,slideTo:_,currentSlide:d,maxSlide:k,minSlide:j,middleSlide:Z};o({updateBreakpointsConfigs:D,updateSlidesData:I,updateSlideWidth:N,initDefaultConfigs:Y,restartCarousel:ue,slideTo:_,next:R,prev:U,nav:le,data:ce});const G=a.default||a.slides,W=a.addons,de=M(ce);return()=>{const t=pe(G?.(de)),m=W?.(de)||[];t.forEach((z,F)=>z.props.index=F);let u=t;if(i.wrapAround){const z=t.map((q,E)=>fe(q,{index:-t.length+E,isClone:!0,key:`clone-before-${E}`})),F=t.map((q,E)=>fe(q,{index:t.length+E,isClone:!0,key:`clone-after-${E}`}));u=[...z,...t,...F]}g.value=t,f.value=Math.max(t.length,1);const b=y("ol",{class:"carousel__track",style:we.value,onMousedownCapture:i.mouseDrag?ne:null,onTouchstartPassiveCapture:i.touchDrag?ne:null},u),ve=y("div",{class:"carousel__viewport"},b);return y("section",{ref:r,class:{carousel:!0,"is-sliding":T.value,"is-dragging":H.value,"is-hover":V.value,"carousel--rtl":i.dir==="rtl"},dir:i.dir,"aria-label":i.i18n.ariaGallery,tabindex:"0",onMouseenter:Se,onMouseleave:be},[ve,m,y(je)])}}}),ge;(function(e){e.arrowUp="arrowUp",e.arrowDown="arrowDown",e.arrowRight="arrowRight",e.arrowLeft="arrowLeft"})(ge||(ge={}));const De=()=>{const e=h("config",M(Object.assign({},v))),a=h("maxSlide",s(1)),n=h("minSlide",s(1)),o=h("currentSlide",s(1)),l=h("nav",{}),r=c=>B({val:o.value,max:a.value,min:0})===c,g=[];for(let c=n.value;c<a.value+1;c++){const f=y("button",{type:"button",class:{"carousel__pagination-button":!0,"carousel__pagination-button--active":r(c)},"aria-label":he(e.i18n.ariaNavigateToSlide,{slideNumber:c+1}),onClick:()=>l.slideTo(c)}),i=y("li",{class:"carousel__pagination-item",key:c},f);g.push(i)}return y("ol",{class:"carousel__pagination"},g)};var Ie=Q({name:"CarouselSlide",props:{index:{type:Number,default:1},isClone:{type:Boolean,default:!1}},setup(e,{slots:a}){const n=h("config",M(Object.assign({},v))),o=h("currentSlide",s(0)),l=h("slidesToScroll",s(0)),r=h("isSliding",s(!1)),g=O(()=>e.index===o.value),c=O(()=>e.index===o.value-1),f=O(()=>e.index===o.value+1),i=O(()=>{const S=Math.floor(l.value),x=Math.ceil(l.value+n.itemsToShow-1);return e.index>=S&&e.index<=x});return()=>{var S;return y("li",{style:{width:`${100/n.itemsToShow}%`},class:{carousel__slide:!0,"carousel__slide--clone":e.isClone,"carousel__slide--visible":i.value,"carousel__slide--active":g.value,"carousel__slide--prev":c.value,"carousel__slide--next":f.value,"carousel__slide--sliding":r.value},"aria-hidden":!i.value},(S=a.default)===null||S===void 0?void 0:S.call(a,{isActive:g.value,isClone:e.isClone,isPrev:c.value,isNext:f.value,isSliding:r.value,isVisible:i.value}))}}});export{Ee as C,De as P,Ie as S};