import{a as e,n as t}from"./chunk-BneVvdWh.js";import{t as n}from"./react-C7IZe2D1.js";import{t as r}from"./jsx-runtime-C2wGStra.js";import{r as i,t as a}from"./OnboardingTooltip-CFzGjB8g.js";import{i as o,r as s}from"./lib-8ue2PVWI.js";var c,l,u=t((()=>{c=`counter__ArBS-`,l={counter:c}})),d,f,p,m,h,g=t((()=>{d=e(n(),1),i(),u(),s(),f=r(),p=({totalSteps:e,nextActionLabel:t=(0,f.jsx)(o,{id:`preply-ds.onboardingTour.nextActionLabel`,defaultMessage:`Next`,description:`Onboarding tour next action label`}),completeActionLabel:n=(0,f.jsx)(o,{id:`preply-ds.onboardingTour.completeActionLabel`,defaultMessage:`Got it`,description:`Onboarding tour complete action label`}),onClose:r,onComplete:i,onStepChange:a,disabled:s,children:c,ctx:l})=>{let[u,p]=(0,d.useState)(!0),[m,h]=(0,d.useState)(0),g={totalSteps:e,nextActionLabel:t,completeActionLabel:n,onClose:()=>{p(!1),r?.()},active:!s&&u,currentStep:m,onActionClick:()=>{if(m===e-1)i?.(),p(!1);else{let e=m+1;h(e),a?.(e)}}};return(0,f.jsx)(l.Provider,{value:g,children:c})},m=(0,d.forwardRef)(function({ctx:e,...t},n){let r=(0,d.useContext)(e);if(!r)throw Error(`OnboardingTourContext not found`);let{currentStep:i,totalSteps:s,onActionClick:c,onClose:u,active:p,nextActionLabel:m,completeActionLabel:h}=r,g=t.step===s-1,_=t.step===i,v=g?h:m,y=()=>{t.actionOnClick?.(),c()},b=e=>{e||u?.()};return(0,f.jsx)(a,{...t,counter:(0,f.jsx)(`p`,{className:l.counter,children:(0,f.jsx)(o,{id:`preply-ds.onboardingTour.counter`,defaultMessage:`{currentStep} of {totalSteps}`,description:`Onboarding tour step counter, e.g. '1 of 3'`,values:{currentStep:i+1,totalSteps:s}})}),open:p&&_,onOpenChange:b,actionLabel:v,actionOnClick:y,ref:n})}),h=()=>{let e=(0,d.createContext)(null);return{Provider:t=>(0,f.jsx)(p,{...t,ctx:e}),Step:(0,d.forwardRef)(function(t,n){return(0,f.jsx)(m,{...t,ctx:e,ref:n})})}};try{h.displayName=`createOnboardingTour`,h.__docgenInfo={description:`Creates a new onboarding tour.

This factory pattern allows multiple independent tours to be nested within each other
without context conflicts, as each tour maintains its own separate context and state.`,displayName:`createOnboardingTour`,props:{}}}catch{}}));export{g as n,h as t};