import{r as l,j as e}from"./@radix-B1sy0Lhr.js";import{u as m,S as x,a as v,b as j}from"./form-schemas-BjWDRvGd.js";import{E as w}from"./EmptyState-BMA34iVR.js";import{A as y,a as A,P as g,S as P}from"./primary-role-CjkpP9fL.js";import{f as _}from"./@react-router-CHjLNlgw.js";import{x as b,F as U,G as C,H as F,t as k,v as E,w as N}from"./index-CO6UN3UX.js";import{c as H}from"./@tanstack-Dwlisomv.js";import{u as M}from"./login-mutation-CDgTlQBD.js";import{S as D}from"./SetPassword-C4OH-cn1.js";import"./check-circle-CG6XAdk-.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";import"./PasswordChecker-DOPLfvg7.js";const d=l.createContext(null);function T({children:t,initialUser:r}){const[a,s]=l.useState(r||{});return e.jsx(d.Provider,{value:{newUser:a,setNewUser:s},children:t})}function p(){const t=l.useContext(d);if(t===null)throw new Error("useActivationContext must be used within an ActivationProvider");return t}function I(){const{setSurveyStep:t}=m(),{setNewUser:r,newUser:a}=p();function s({fullName:n,getUpdates:o,email:i}){r(c=>({...c,...i?{email:i}:{email:null},full_name:n,email_opted_in:o})),t(c=>c+1)}return e.jsx(y,{email:a.email,fullName:a.full_name,submitHandler:s})}async function L({userId:t,body:r}){const a=U(F.users.activate(t)),s=await b(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok){const n=await s.json().then(o=>Array.isArray(o.detail)?o.detail[1]:o.detail).catch(()=>"Failed to update activate user");throw new C({status:s.status,statusText:s.statusText,message:n})}return s.json()}function R(t){return H({mutationFn:async r=>L(r),...t})}function z({userId:t,setUsername:r}){const{newUser:a}=p(),{setAuthState:s}=k(),{setSurveyStep:n}=m(),{mutate:o}=M({onSuccess:()=>{s("true"),n(u=>u+1)}}),{toast:i}=E(),{mutate:c}=R({onSuccess:async u=>{r(u.name),o({username:u.name,password:a.password??void 0})},onError:u=>{u instanceof Error&&i({status:"error",emphasis:"subtle",icon:e.jsx(N,{className:"h-5 w-5 shrink-0 fill-error-700"}),description:u.message,rounded:!0})}});function f({aiTypes:u,biggestChallenge:S}){const h={ai_types_working_with:u,biggest_ai_challenges:S,finished_onboarding_survey:!0};c({userId:t,body:{...a,user_metadata:{...a.user_metadata,...h}}})}return e.jsx(A,{submitHandler:f})}function G(){const{setSurveyStep:t}=m(),{setNewUser:r}=p();function a({newPassword:s}){r(n=>({...n,password:s})),t(n=>n+1)}return e.jsx(D,{submitHandler:a})}function J(){const{setSurveyStep:t}=m(),{setNewUser:r}=p();function a({primaryRole:s,otherVal:n}){const o={primary_role:s==="other"?n:s};r(i=>({...i,user_metadata:{...i.user_metadata,...o}})),t(i=>i+1)}return e.jsx(g,{submitHandler:a})}function O(){const{surveyStep:t}=m(),[r]=_(),[a,s]=l.useState(""),n=r.get("user"),o=r.get("token");return!n||!o?e.jsx(w,{children:e.jsx("p",{children:"Invalid activation link."})}):e.jsx(e.Fragment,{children:e.jsxs(T,{initialUser:{activation_token:o},children:[e.jsx(x,{stepAmount:5}),t===1&&e.jsx(I,{}),t===2&&e.jsx(G,{}),t===3&&e.jsx(J,{}),t===4&&e.jsx(z,{setUsername:s,userId:n}),t===5&&e.jsx(P,{}),t===6&&e.jsx(v,{subHeader:"Your created your ZenML account",username:a})]})})}function ft(){return e.jsx("div",{children:e.jsx(j,{children:e.jsx(O,{})})})}export{ft as default};
