"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),a=require("react"),m=require("../../utils/cn/cn.cjs.js"),r=require("../../src/components/StepsCarousel/stepsCarousel.module.css"),g=require("../Label/Label.cjs.js"),b=require("../Typography/Typography.cjs.js"),C=require("../ProgressButton/ProgressButton.cjs.js"),v=50,T=({steps:d,colorScheme:i})=>{const[s,j]=a.useState(0),p=a.useRef(null),f=a.useRef([]),c=a.useRef(null),h=a.useRef(null),x=a.useCallback(e=>{c.current={x:e.touches[0].clientX,y:e.touches[0].clientY}},[]),o=a.useCallback(e=>{var t;j(e),(t=f.current[e])==null||t.scrollIntoView({behavior:"smooth",inline:"center",block:"nearest"})},[]),y=a.useCallback(()=>{if(c.current!==null&&h.current!==null){const e=h.current-c.current.x;let t=s;e>v&&s>0?t=s-1:e<-v&&s<d.length-1&&(t=s+1),t!==s&&o(t)}c.current=null,h.current=null},[s,d.length,o]);return a.useEffect(()=>{const e=p.current;if(!e)return;const t=l=>{if(c.current===null)return;const u=l.touches[0].clientX,S=l.touches[0].clientY,N=Math.abs(u-c.current.x),k=Math.abs(S-c.current.y);N>k&&(l.preventDefault(),h.current=u)};return e.addEventListener("touchmove",t,{passive:!1}),()=>{e.removeEventListener("touchmove",t)}},[]),n.jsxs("div",{className:r.root,"data-scheme":i,children:[n.jsx("div",{ref:p,className:r.stepsContainer,"data-scheme":i,onTouchStart:x,onTouchEnd:y,children:d.map((e,t)=>{const l=s===t;return n.jsxs("button",{ref:u=>{u&&(f.current[t]=u)},className:m.cn(r.card,{[r.cardActive]:l}),onClick:()=>o(t),type:"button",children:[n.jsx("div",{className:m.cn(r.imageWrapper,l&&r.imageWrapperActive),children:n.jsx("img",{src:e.image,alt:e.title,className:r.image})}),n.jsx("div",{className:r.stepLabel,children:l?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:r.desktop,children:n.jsx(g.Label,{size:"lg",color:i==="dark"?"white":"black",children:e.name||`Step ${t+1}`})}),n.jsx("div",{className:r.mobile,children:n.jsx(g.Label,{size:"sm",color:i==="dark"?"white":"black",children:e.name||`Step ${t+1}`})})]}):n.jsx(b.Typography,{defaultVariant:"labelSm",mobileVariant:"labelXs",emphasis:!0,className:r.labelText,children:e.name||`Step ${t+1}`})}),n.jsxs("div",{className:r.textContainer,children:[n.jsx(b.Typography,{as:"h3",defaultVariant:"headingSm",mobileVariant:"headingXxs",children:e.title}),e.description&&n.jsx(b.Typography,{as:"p",defaultVariant:"bodyMd",mobileVariant:"bodySm",className:r.cardDescription,children:e.description})]})]},`step-${t}`)})}),n.jsx("div",{className:m.cn(r.mobile,r.progressButtonContainer),children:n.jsx(C.ProgressButton,{invert:i==="dark",left:{disabled:s<=0,onClick:()=>o(s-1)},right:{disabled:s>=d.length-1,onClick:()=>o(s+1)}})})]})};exports.StepsCarousel=T;
