import{r as c,j as e}from"./@radix-B1sy0Lhr.js";import{u as l,S as x,a as y,b as f}from"./form-schemas-BjWDRvGd.js";import{A as h,a as v,P as j,S as _}from"./primary-role-CjkpP9fL.js";import{v as g,w as C,bg as b,u as U,d as w}from"./index-CO6UN3UX.js";import{u as P}from"./update-current-user-mutation-B3Dpv3u6.js";import{h as A}from"./@tanstack-Dwlisomv.js";import"./check-circle-CG6XAdk-.js";import"./@react-router-CHjLNlgw.js";import"./UpdatePasswordSchemas-DNkYgzN6.js";import"./zod-D48zuELD.js";import"./index.esm-SBF9nn_P.js";import"./bar-chart-square-check-_m-oYysN.js";import"./dataflow-2-BLkaTH0Q.js";import"./credit-card-DfBA6dBb.js";import"./eye-BXcQevds.js";import"./file-text-TdPXNd7s.js";import"./layout-GIiNvS10.js";import"./message-chat-square-C3CRCQvD.js";import"./slash-circle-B0xMh8q6.js";import"./transform-S7omcvTm.js";import"./@reactflow-gbyyU3kq.js";const d=c.createContext(null);function E({children:t,initialUser:s}){const[n,r]=c.useState(s||{});return e.jsx(d.Provider,{value:{user:n,setUser:r},children:t})}function p(){const t=c.useContext(d);if(t===null)throw new Error("useSurveyUserContext must be used within an SurveyUserProvider");return t}function k({user:t}){var o,u;const{setSurveyStep:s}=l(),{setUser:n}=p();function r({fullName:a,getUpdates:m,email:i}){n(S=>({...S,...i?{email:i}:{email:null},full_name:a,email_opted_in:m})),s(2)}return e.jsx(h,{email:(o=t.metadata)==null?void 0:o.email,fullName:(u=t.body)==null?void 0:u.full_name,submitHandler:r})}function D(){const{user:t}=p(),{setSurveyStep:s}=l(),{toast:n}=g(),r=A(),{mutate:o}=P({onSuccess:async()=>{await r.invalidateQueries({queryKey:b()}),s(a=>a+1)},onError:a=>{a instanceof Error&&n({status:"error",emphasis:"subtle",icon:e.jsx(C,{className:"h-5 w-5 shrink-0 fill-error-700"}),description:a.message,rounded:!0})}});function u({biggestChallenge:a,aiTypes:m}){const i={ai_types_working_with:m,biggest_ai_challenges:a,finished_onboarding_survey:!0};o({...t,user_metadata:{...t.user_metadata,...i}})}return e.jsx(v,{submitHandler:u})}function F({user:t}){const{setSurveyStep:s}=l(),{setUser:n}=p();function r({primaryRole:o,otherVal:u}){const m={primary_role:o==="other"?u:o};n(i=>({...i,user_metadata:{...i.user_metadata,...m}})),s(3)}return e.jsx(j,{user:t,submitHandler:r})}function H(){const{data:t,isPending:s,isError:n}=U({throwOnError:!0}),{surveyStep:r}=l();return n?null:s?e.jsx(w,{className:"h-[300px]"}):e.jsx(e.Fragment,{children:e.jsxs(E,{children:[e.jsx(x,{stepAmount:4}),r===1&&e.jsx(k,{user:t}),r===2&&e.jsx(F,{user:t}),r===3&&e.jsx(D,{}),r===4&&e.jsx(_,{}),r===5&&e.jsx(y,{subHeader:"Your ZenML account is now updated",displayBody:!1,username:t.name})]})})}function te(){return e.jsx("div",{children:e.jsx(f,{children:e.jsx(H,{})})})}export{te as default};
