import{ao as a,h$ as v,aO as M,i0 as S,aI as K,aq as L,bq as Y,az as C,aj as _,i1 as z,bs as G,hZ as U,o as V,E as J,bc as Z,ay as Q,bI as W,ge as X,r as E,dJ as T,dL as D,d as F,v as f,f as $,e as H,L as ee,i2 as ae}from"./app-k0jcl5PQ.js";import{u as j}from"./BZ-tsgAq.chunk.js";import{L as h}from"./CCKlkV4O.chunk.js";import{u as te}from"./CECGJrz_.chunk.js";import{U as ne}from"./Cq8Wr_gd.chunk.js";const se="_heading_77xoi_1",re={heading:se};function ke(e){return a.jsx("h1",{className:`${re.heading} ${e.className}`,children:e.children})}function ye(e){return a.jsx("p",{className:e.className,children:e.children})}const ie="_progressBar_u8bom_1",ce="_currentStep_u8bom_8",I={progressBar:ie,currentStep:ce};function oe(e){const{totalScreensInProgressBar:s,currentStepProgressBarNumber:c,progressBarPercentage:l,showProgressBar:d}=v.getProgress(e.pathway);return d?a.jsxs("div",{className:`${I.progressBar} position-absolute rounded-pill bg-light-blue d-flex align-items-center`,children:[a.jsxs("div",{className:I.currentStep,children:[c," / ",s]}),a.jsx("div",{className:"flex-grow-1 h-50",children:a.jsx("div",{className:"h-100 rounded-pill bg-green",style:{width:`${l}%`}})})]}):a.jsx(a.Fragment,{})}const P="onboarding.onboardingLayout";function q(e){const{hasLoadedPathway:s}=j(S());return s?a.jsx(M.Provider,{value:e.namespace,children:a.jsx(h,{children:e.children})}):a.jsx(a.Fragment,{})}function le(e){return a.jsx(h.Left,{className:e.className,children:e.children})}function de(e){const[s,c]=K.useState(!1),l=S(),{getPathway:d,hasLoadedPathway:g}=j(l),n=d();async function m(){if(e.hasCustomButtons!==!0){c(!0);try{await e.onClickNext()}catch{c(!1)}}}if(!g)return a.jsx(a.Fragment,{});const t=n.screens[n.currentScreen];return a.jsxs(h.Right,{className:e.className,children:[a.jsx(h.Header,{children:a.jsx(oe,{pathway:n})}),a.jsx(h.Content,{children:e.children}),e.hasCustomButtons===!1&&a.jsxs(h.Buttons,{children:[e.onClickComeBackLater&&a.jsx("button",{className:"btn btn-link btn-lg text-info",onClick:e.onClickComeBackLater,children:a.jsx(L,{namespace:P,phrase:"comeBackLater"})}),e.onClickAreYouATeacher&&a.jsx("button",{className:"btn btn-link btn-lg text-info text-start",onClick:e.onClickAreYouATeacher,children:a.jsx(L,{namespace:P,phrase:"areYouATeacher"})}),a.jsxs("div",{className:"d-flex ms-auto",children:[!!(t!=null&&t.previous)&&a.jsx("button",{className:"btn btn-outline-dark btn-lg me-2",onClick:e.onClickBack,children:a.jsx(L,{namespace:P,phrase:"back"})}),a.jsx(Y,{className:`${e.disableNext?"disabled":""}`,onClick:m,disabled:e.disableNext,showSpinner:s,variant:"dark",size:"lg",children:e.nextText?e.nextText:a.jsx(L,{namespace:P,phrase:t!=null&&t.next?(t==null?void 0:t.next)===(t==null?void 0:t.previous)?"save":"next":"finish"})})]})]})]})}q.Left=le;q.Right=de;function ue(){const e=S(),{getPathway:s}=j(e),c=C(_.currentUser()),l=C(_.user(c.data.id)),d=C(ne.currentProspect()),g=z(),n=G(),m=g?"kdm":"teacher";function t(p,w,O={},N={}){var x,b,k,R;const u=s(N),o=U[u.currentScreen],A=v.getProgress(u),i=u.screens[u.currentScreen],y=i==null?void 0:i.next,r=i==null?void 0:i.previous,B={jobTitle:(k=(b=(x=l.data)==null?void 0:x.userProfile)==null?void 0:b.metadata)==null?void 0:k.jobTitle,prospectId:(R=d.data)==null?void 0:R.id};V.logUserAction({currentScreen:o==null?void 0:o.id,nextScreen:y,previousScreen:r,progress:A,pathway:m,isTertiary:n,...B,...v.getOnboardingScreenStates(u),...O},{actionType:p,descriptor:w,location:o==null?void 0:o.analyticsLocation,entity:J.User})}return{logEvent:t}}const ge="onboarding.hooks";function Le(e){const s=S(e),{getPathway:c,commitPathway:l,waitForFreshPathwayDataAsync:d}=j(s),g=c(),n=U[g.currentScreen],m=Z(),{logEvent:t}=ue(),{updateUserSettingAsync:p}=Q(n==null?void 0:n.analyticsLocation),{activePresentation:w}=W(),{preferredPresentation:O}=X(),{setTeachingLevelFromPresentationAsync:N}=te();async function u(r={isExiting:!1}){const B=n==null?void 0:n.id;if(await p({name:n==null?void 0:n.setting,value:!0,kind:D.Setting}),r.isExiting){i({hasLoader:!0});return}await d();const x=l(r),b=x.screens[B],k=b?b.next:x.currentScreen;if(!k){await y();return}f.trigger(s[k])}function o(){m.error(ee.getPhrase(ge,"saveError"))}function A(){t(E.Click,T.Back);const r=v.getPreviousAppLink(g,s);f.trigger(r)}function i(r={hasLoader:!1}){t(E.Click,T.ComeBackLater),p({name:F.HasExitedOnboarding,value:!0,kind:D.Setting}).then(()=>{if(r.hasLoader){f.trigger({application:H.ONBOARDING,action:$.Onboarding.COMPLETED_LOADER,params:{redirectUrl:e}});return}ae(e,null)})}async function y(){t(E.Complete,T.Complete),await p({name:F.HasCompletedOnboardingV2,value:!0,kind:D.Setting});try{await N(O??w)}catch(r){console.error("Error occurred while attempting to set teaching level",r)}f.trigger({application:H.ONBOARDING,action:$.Onboarding.COMPLETED_LOADER,params:{redirectUrl:e}})}return{onClickBack:A,exitOnboarding:i,onSaveError:o,completeStepAsync:u,completeOnboarding:y}}export{q as O,ue as a,ke as b,ye as c,Le as u};
//# sourceMappingURL=JiP4blAc.chunk.js.map
