import{r as u,bp as C,u as p,y,j as e,$ as I,a as o,b as m,c as P,d as n,g as E,f as h,au as D,v as U,bq as R,br as T}from"./index-f9c70843.js";import{I as j}from"./index-ec47a6a3.js";import{I as _}from"./input-ae70f3cc.js";import"./popover-6c4eec5c.js";function F(){const[f,v]=u.useState(C),[w,t]=u.useState(!0),{password:a,cnfPassword:r,username:i}=f,N=p(s=>s.setSuccessData),b=p(s=>s.setErrorData),g=y();function l({target:{name:s,value:c}}){v(d=>({...d,[s]:c}))}u.useEffect(()=>{if(a!==r||a===""||r===""||i==="")return t(!0);t(!1)},[a,r,i,l]);function S(){const{username:s,password:c}=f,d={username:s.trim(),password:c.trim()};U(d).then(x=>{N({title:R}),g("/login")}).catch(x=>{const{response:{data:{detail:$}}}=x;b({title:T,list:[$]})})}return e.jsx(I,{onSubmit:s=>{if(a===""){s.preventDefault();return}Object.fromEntries(new FormData(s.currentTarget)),s.preventDefault()},className:"h-full w-full",children:e.jsx("div",{className:"flex h-full w-full flex-col items-center justify-center bg-muted",children:e.jsxs("div",{className:"flex w-72 flex-col items-center justify-center gap-2",children:[e.jsx("span",{className:"mb-4 text-5xl",children:"⛓️"}),e.jsx("span",{className:"mb-6 text-2xl font-semibold text-primary",children:"Sign up to Langflow"}),e.jsx("div",{className:"mb-3 w-full",children:e.jsxs(o,{name:"username",children:[e.jsxs(m,{className:"data-[invalid]:label-invalid",children:["Username ",e.jsx("span",{className:"font-medium text-destructive",children:"*"})]}),e.jsx(P,{asChild:!0,children:e.jsx(_,{type:"username",onChange:({target:{value:s}})=>{l({target:{name:"username",value:s}})},value:i,className:"w-full",required:!0,placeholder:"Username"})}),e.jsx(n,{match:"valueMissing",className:"field-invalid",children:"Please enter your username"})]})}),e.jsx("div",{className:"mb-3 w-full",children:e.jsxs(o,{name:"password",serverInvalid:a!=r,children:[e.jsxs(m,{className:"data-[invalid]:label-invalid",children:["Password ",e.jsx("span",{className:"font-medium text-destructive",children:"*"})]}),e.jsx(j,{onChange:s=>{l({target:{name:"password",value:s}})},value:a,isForm:!0,password:!0,required:!0,placeholder:"Password",className:"w-full"}),e.jsx(n,{className:"field-invalid",match:"valueMissing",children:"Please enter a password"}),a!=r&&e.jsx(n,{className:"field-invalid",children:"Passwords do not match"})]})}),e.jsx("div",{className:"w-full",children:e.jsxs(o,{name:"confirmpassword",serverInvalid:a!=r,children:[e.jsxs(m,{className:"data-[invalid]:label-invalid",children:["Confirm your password"," ",e.jsx("span",{className:"font-medium text-destructive",children:"*"})]}),e.jsx(j,{onChange:s=>{l({target:{name:"cnfPassword",value:s}})},value:r,isForm:!0,password:!0,required:!0,placeholder:"Confirm your password",className:"w-full"}),e.jsx(n,{className:"field-invalid",match:"valueMissing",children:"Please confirm your password"})]})}),e.jsx("div",{className:"w-full",children:e.jsx(E,{asChild:!0,children:e.jsx(h,{disabled:w,type:"submit",className:"mr-3 mt-6 w-full",onClick:()=>{S()},children:"Sign up"})})}),e.jsx("div",{className:"w-full",children:e.jsx(D,{to:"/login",children:e.jsxs(h,{className:"w-full",variant:"outline",children:["Already have an account? ",e.jsx("b",{children:"Sign in"})]})})})]})})})}export{F as default};
