import{r as c,aJ as e,aQ as S}from"./@ui-core-DKdciH1Z.js";import{u as l,S as x,a as y,b as f}from"./form-schemas-CtQXlH0G.js";import{A as h,a as v,P as j,S as _}from"./primary-role-T4nm9YYN.js";import{x as C,y as g,ce as b,u as U,e as P}from"./index-D7KLAbvI.js";import{u as w}from"./update-current-user-mutation-BGVZeLEX.js";import"./@react-router-DaIuhn3X.js";import"./@zod-DKyD3xVW.js";import"./UpdatePasswordSchemas-C1WO1M58.js";import"./bar-chart-square-check-Lt3fLSJ-.js";import"./dataflow-2-iGdAJFn_.js";import"./credit-card-DizUoT70.js";import"./eye-0EFEzbgA.js";import"./file-text-BLW8J__B.js";import"./layout-BRN9AeDt.js";import"./message-chat-square-SV9o-mj_.js";import"./slash-circle-DHtQ7yx0.js";import"./transform-Bq7p9csj.js";import"./@reactflow-CJzATMj6.js";import"./@monaco-editor-CSMpaClf.js";const d=c.createContext(null);function A({children:t,initialUser:n}){const[a,r]=c.useState(n||{});return e.jsx(d.Provider,{value:{user:a,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 E({user:t}){const{setSurveyStep:n}=l(),{setUser:a}=p();function r({fullName:o,getUpdates:u,email:s}){a(i=>({...i,...s?{email:s}:{email:null},full_name:o,email_opted_in:u})),n(2)}return e.jsx(h,{email:t.metadata?.email,fullName:t.body?.full_name,submitHandler:r})}function k(){const{user:t}=p(),{setSurveyStep:n}=l(),{toast:a}=C(),r=S(),{mutate:o}=w({onSuccess:async()=>{await r.invalidateQueries({queryKey:b()}),n(s=>s+1)},onError:s=>{s instanceof Error&&a({status:"error",emphasis:"subtle",icon:e.jsx(g,{className:"h-5 w-5 shrink-0 fill-error-700"}),description:s.message,rounded:!0})}});function u({biggestChallenge:s,aiTypes:i}){const m={ai_types_working_with:i,biggest_ai_challenges:s,finished_onboarding_survey:!0};o({...t,user_metadata:{...t.user_metadata,...m}})}return e.jsx(v,{submitHandler:u})}function D({user:t}){const{setSurveyStep:n}=l(),{setUser:a}=p();function r({primaryRole:o,otherVal:u}){const i={primary_role:o==="other"?u:o};a(m=>({...m,user_metadata:{...m.user_metadata,...i}})),n(3)}return e.jsx(j,{user:t,submitHandler:r})}function F(){const{data:t,isPending:n,isError:a}=U({throwOnError:!0}),{surveyStep:r}=l();return a?null:n?e.jsx(P,{className:"h-[300px]"}):e.jsx(e.Fragment,{children:e.jsxs(A,{children:[e.jsx(x,{stepAmount:4}),r===1&&e.jsx(E,{user:t}),r===2&&e.jsx(D,{user:t}),r===3&&e.jsx(k,{}),r===4&&e.jsx(_,{}),r===5&&e.jsx(y,{subHeader:"Your ZenML account is now updated",displayBody:!1,username:t.name})]})})}function X(){return e.jsx("div",{children:e.jsx(f,{children:e.jsx(F,{})})})}export{X as default};
