import{cW as q,r as c,j as w}from"./vendor-BKmmeuxg.js";import{c as N}from"./utils-DxSsnXxD.js";import"./button-BpNwv2aE.js";const T=c.createContext(null);function P(){const o=c.useContext(T);if(!o)throw new Error("useCarousel must be used within a ");return o}function $({orientation:o="horizontal",opts:t,setApi:e,plugins:u,className:y,children:p,...d}){const[s,n]=q({...t,axis:o==="horizontal"?"x":"y"},u),[x,m]=c.useState(!1),[h,O]=c.useState(!1),f=c.useCallback(a=>{a&&(m(a.canScrollPrev()),O(a.canScrollNext()))},[]),S=c.useCallback(()=>{n==null||n.scrollPrev()},[n]),l=c.useCallback(()=>{n==null||n.scrollNext()},[n]),i=c.useCallback(a=>{a.key==="ArrowLeft"?(a.preventDefault(),S()):a.key==="ArrowRight"&&(a.preventDefault(),l())},[S,l]);return c.useEffect(()=>{!n||!e||e(n)},[n,e]),c.useEffect(()=>{if(n)return f(n),n.on("reInit",f),n.on("select",f),()=>{n==null||n.off("select",f)}},[n,f]),w.jsx(T.Provider,{value:{carouselRef:s,api:n,opts:t,orientation:o||((t==null?void 0:t.axis)==="y"?"vertical":"horizontal"),scrollPrev:S,scrollNext:l,canScrollPrev:x,canScrollNext:h},children:w.jsx("div",{onKeyDownCapture:i,className:N("relative",y),role:"region","aria-roledescription":"carousel","data-slot":"carousel",...d,children:p})})}function ee({className:o,...t}){const{carouselRef:e,orientation:u}=P();return w.jsx("div",{ref:e,className:"overflow-hidden","data-slot":"carousel-content",children:w.jsx("div",{className:N("flex",u==="horizontal"?"-ml-4":"-mt-4 flex-col",o),...t})})}function te({className:o,...t}){const{orientation:e}=P();return w.jsx("div",{role:"group","aria-roledescription":"slide","data-slot":"carousel-item",className:N("min-w-0 shrink-0 grow-0 basis-full",e==="horizontal"?"pl-4":"pt-4",o),...t})}const G={active:!0,breakpoints:{},delay:4e3,jump:!1,playOnInit:!0,stopOnFocusIn:!0,stopOnInteraction:!0,stopOnMouseEnter:!1,stopOnLastSnap:!1,rootNode:null};function J(o,t){const e=o.scrollSnapList();return typeof t=="number"?e.map(()=>t):t(e,o)}function Q(o,t){const e=o.rootNode();return t&&t(e)||e}function A(o={}){let t,e,u,y,p=null,d=0,s=!1,n=!1,x=!1,m=!1;function h(r,g){e=r;const{mergeOptions:v,optionsAtMedia:b}=g,B=v(G,A.globalOptions),H=v(B,o);if(t=b(H),e.scrollSnapList().length<=1)return;m=t.jump,u=!1,y=J(e,t.delay);const{eventStore:C,ownerDocument:V}=e.internalEngine(),j=!!e.internalEngine().options.watchDrag,k=Q(e,t.rootNode);C.add(V,"visibilitychange",a),j&&e.on("pointerDown",E),j&&!t.stopOnInteraction&&e.on("pointerUp",I),t.stopOnMouseEnter&&C.add(k,"mouseenter",L),t.stopOnMouseEnter&&!t.stopOnInteraction&&C.add(k,"mouseleave",z),t.stopOnFocusIn&&e.on("slideFocusStart",i),t.stopOnFocusIn&&!t.stopOnInteraction&&C.add(e.containerNode(),"focusout",l),t.playOnInit&&l()}function O(){e.off("pointerDown",E).off("pointerUp",I).off("slideFocusStart",i),i(),u=!0,s=!1}function f(){const{ownerWindow:r}=e.internalEngine();r.clearTimeout(d),d=r.setTimeout(W,y[e.selectedScrollSnap()]),p=new Date().getTime(),e.emit("autoplay:timerset")}function S(){const{ownerWindow:r}=e.internalEngine();r.clearTimeout(d),d=0,p=null,e.emit("autoplay:timerstopped")}function l(){if(!u){if(D()){x=!0;return}s||e.emit("autoplay:play"),f(),s=!0}}function i(){u||(s&&e.emit("autoplay:stop"),S(),s=!1)}function a(){if(D())return x=s,i();x&&l()}function D(){const{ownerDocument:r}=e.internalEngine();return r.visibilityState==="hidden"}function E(){n||i()}function I(){n||l()}function L(){n=!0,i()}function z(){n=!1,l()}function R(r){typeof r<"u"&&(m=r),l()}function F(){s&&i()}function M(){s&&l()}function U(){return s}function W(){const{index:r}=e.internalEngine(),g=r.clone().add(1).get(),v=e.scrollSnapList().length-1,b=t.stopOnLastSnap&&g===v;if(e.canScrollNext()?e.scrollNext(m):e.scrollTo(0,m),e.emit("autoplay:select"),b)return i();l()}function K(){if(!p)return null;const r=y[e.selectedScrollSnap()],g=new Date().getTime()-p;return r-g}return{name:"autoplay",options:o,init:h,destroy:O,play:R,stop:F,reset:M,isPlaying:U,timeUntilNext:K}}A.globalOptions=void 0;export{A,$ as C,ee as a,te as b};