import{j as e,b as v}from"./@tanstack-CEbkxrhX.js";import{u as m,S as w,a as j,b as y}from"./SuccessStep-CykrFndS.js";import{A,P,a as b}from"./AwarenessChannel-B2KR83Tr.js";import{r as l}from"./@radix-C9DBgJhe.js";import{S as U}from"./SetPassword-CiNhT15a.js";import{j as _,F as g,k as F,l as C,e as E,f as k,i as N}from"./index-BawkpTlr.js";import{u as M}from"./login-mutation-Bk2tn324.js";import{b as D}from"./@react-router-DYovave8.js";import{E as H}from"./EmptyState-BkooiGtL.js";import"./UpdatePasswordSchemas-CKrd3UZz.js";import"./check-circle-BVvhm5dy.js";import"./url-CgvM-IVM.js";import"./zod-DrZvVLjd.js";import"./index.esm-F7nqy9zY.js";import"./file-text-CbVERUON.js";import"./play-circle-DK5QMJyp.js";import"./PasswordChecker-DSLBp7Vl.js";import"./@reactflow-DYIyhCfd.js";const f=l.createContext(null);function T({children:t,initialUser:r}){const[n,s]=l.useState(r||{});return e.jsx(f.Provider,{value:{newUser:n,setNewUser:s},children:t})}function d(){const t=l.useContext(f);if(t===null)throw new Error("useActivationContext must be used within an ActivationProvider");return t}function I(){const{setSurveyStep:t}=m(),{setNewUser:r,newUser:n}=d();function s({fullName:a,getUpdates:o,email:i}){r(c=>({...c,...i?{email:i}:{email:null},full_name:a,email_opted_in:o})),t(c=>c+1)}return e.jsx(A,{email:n.email,fullName:n.full_name,submitHandler:s})}function L(){const{setSurveyStep:t}=m(),{setNewUser:r}=d();function n({newPassword:s}){r(a=>({...a,password:s})),t(a=>a+1)}return e.jsx(U,{submitHandler:n})}function z(){const{setSurveyStep:t}=m(),{setNewUser:r}=d();function n({amountProductionModels:s,primaryUse:a}){const o={primary_use:a,models_production:s};r(i=>({...i,user_metadata:{...i.user_metadata,...o}})),t(i=>i+1)}return e.jsx(P,{submitHandler:n})}async function J({userId:t,body:r}){const n=F(C.users.activate(t)),s=await _(n,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok){const a=await s.json().then(o=>o.detail instanceof Array?o.detail[1]:o.detail).catch(()=>"Failed to update activate user");throw new g({status:s.status,statusText:s.statusText,message:a})}return s.json()}function O(t){return v({mutationFn:async r=>J(r),...t})}function R({userId:t,setUsername:r}){const{newUser:n}=d(),{setAuthState:s}=E(),{setSurveyStep:a}=m(),{mutate:o}=M({onSuccess:()=>{s("true"),a(u=>u+1)}}),{toast:i}=k(),{mutate:c}=O({onSuccess:async u=>{r(u.name),o({username:u.name,password:n.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 S({other:u,channels:p,otherVal:x}){const h={awareness_channels:u?[...p,x]:p};c({userId:t,body:{...n,user_metadata:{...n.user_metadata,...h}}})}return e.jsx(b,{submitHandler:S})}function W(){const{surveyStep:t}=m(),[r]=D(),[n,s]=l.useState(""),a=r.get("user"),o=r.get("token");return!a||!o?e.jsx(H,{children:e.jsx("p",{children:"Invalid activation link."})}):e.jsx(e.Fragment,{children:e.jsxs(T,{initialUser:{activation_token:o},children:[e.jsx(w,{stepAmount:4}),t===1&&e.jsx(I,{}),t===2&&e.jsx(L,{}),t===3&&e.jsx(z,{}),t===4&&e.jsx(R,{setUsername:s,userId:a}),t===5&&e.jsx(j,{subHeader:"Your created your ZenML account",username:n})]})})}function ct(){return e.jsx("div",{children:e.jsx(y,{children:e.jsx(W,{})})})}export{ct as default};
