import{r as e,bw as S,j as a,A as R,n as k}from"./vendor-laZsiqLO.js";import{c as x}from"./utils-RgT4yCq8.js";import{B as N}from"./button-B8f8jW4H.js";const w=e.createContext(null);function m(){const o=e.useContext(w);if(!o)throw new Error("useCarousel must be used within a <Carousel />");return o}const z=e.forwardRef(({orientation:o="horizontal",opts:s,setApi:l,plugins:t,className:c,children:i,...u},f)=>{const[p,r]=S({...s,axis:o==="horizontal"?"x":"y"},t),[v,y]=e.useState(!1),[b,j]=e.useState(!1),d=e.useCallback(n=>{n&&(y(n.canScrollPrev()),j(n.canScrollNext()))},[]),C=e.useCallback(()=>{r?.scrollPrev()},[r]),h=e.useCallback(()=>{r?.scrollNext()},[r]),P=e.useCallback(n=>{n.key==="ArrowLeft"?(n.preventDefault(),C()):n.key==="ArrowRight"&&(n.preventDefault(),h())},[C,h]);return e.useEffect(()=>{!r||!l||l(r)},[r,l]),e.useEffect(()=>{if(r)return d(r),r.on("reInit",d),r.on("select",d),()=>{r?.off("select",d)}},[r,d]),a.jsx(w.Provider,{value:{carouselRef:p,api:r,opts:s,orientation:o||(s?.axis==="y"?"vertical":"horizontal"),scrollPrev:C,scrollNext:h,canScrollPrev:v,canScrollNext:b},children:a.jsx("div",{ref:f,onKeyDownCapture:P,className:x("relative",c),role:"region","aria-roledescription":"carousel",...u,children:i})})});z.displayName="Carousel";const g=e.forwardRef(({className:o,...s},l)=>{const{carouselRef:t,orientation:c}=m();return a.jsx("div",{ref:t,className:"overflow-hidden",children:a.jsx("div",{ref:l,className:x("flex",c==="horizontal"?"-ml-4":"-mt-4 flex-col",o),...s})})});g.displayName="CarouselContent";const E=e.forwardRef(({className:o,...s},l)=>{const{orientation:t}=m();return a.jsx("div",{ref:l,role:"group","aria-roledescription":"slide",className:x("min-w-0 shrink-0 grow-0 basis-full",t==="horizontal"?"pl-4":"pt-4",o),...s})});E.displayName="CarouselItem";const D=e.forwardRef(({className:o,variant:s="outline",size:l="icon",...t},c)=>{const{orientation:i,scrollPrev:u,canScrollPrev:f}=m();return a.jsxs(N,{ref:c,variant:s,size:l,className:x("absolute  h-8 w-8 rounded-full",i==="horizontal"?"-left-12 top-1/2 -translate-y-1/2":"-top-12 left-1/2 -translate-x-1/2 rotate-90",o),disabled:!f,onClick:u,...t,children:[a.jsx(R,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Previous slide"})]})});D.displayName="CarouselPrevious";const A=e.forwardRef(({className:o,variant:s="outline",size:l="icon",...t},c)=>{const{orientation:i,scrollNext:u,canScrollNext:f}=m();return a.jsxs(N,{ref:c,variant:s,size:l,className:x("absolute h-8 w-8 rounded-full",i==="horizontal"?"-right-12 top-1/2 -translate-y-1/2":"-bottom-12 left-1/2 -translate-x-1/2 rotate-90",o),disabled:!f,onClick:u,...t,children:[a.jsx(k,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Next slide"})]})});A.displayName="CarouselNext";export{z as C,g as a,E as b};
