import{F as r,o as g,b as h,a1 as f,j as e,h as c,B as l,a2 as j,m as i}from"./index-Dg3RqyI3.js";import{R as w,a as d}from"./UserOutlined-CYcHQ2Vd.js";const R=function(){const[u]=r.useForm(),p=g(),{t:s}=h(),o=f(),x=async a=>{var n,t;if(a.password!==a.confirm_password){i.error(s("account.passwordConfirmError"));return}try{await o.mutateAsync(a),i.success(s("account.registerSuccess")),p({to:"/login"})}catch(m){console.error("register failed",m),i.error(((t=(n=m.response)==null?void 0:n.data)==null?void 0:t.detail)||s("account.registerFailed"))}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[url(/bg.png)] p-4",children:e.jsxs("div",{className:"max-w-md w-full space-y-8 bg-white p-10 rounded-xl shadow-lg",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx("img",{src:"/logo.svg",alt:"logo",className:"w-8 h-8"}),e.jsx("span",{className:"text-3xl text-gray-800",children:"Vis3"})]}),e.jsx("p",{className:"mt-2 text-gray-600",children:s("account.createNewAccount")})]}),e.jsxs(r,{form:u,name:"register",initialValues:{remember:!0},onFinish:x,size:"large",className:"mt-8 space-y-6",children:[e.jsx(r.Item,{name:"username",rules:[{required:!0,message:s("account.usernameRequired")},{min:3,message:s("account.usernameMinLength")}],children:e.jsx(c,{prefix:e.jsx(w,{className:"site-form-item-icon"}),placeholder:s("account.username")})}),e.jsx(r.Item,{name:"password",rules:[{required:!0,message:s("account.passwordRequired")},{min:6,message:s("account.passwordMinLength")}],children:e.jsx(c.Password,{prefix:e.jsx(d,{className:"site-form-item-icon"}),placeholder:s("account.password")})}),e.jsx(r.Item,{name:"confirm_password",dependencies:["password"],rules:[{required:!0,message:s("account.passwordConfirmRequired")},({getFieldValue:a})=>({validator(n,t){return!t||a("password")===t?Promise.resolve():Promise.reject(new Error(s("account.passwordConfirmError")))}})],children:e.jsx(c.Password,{prefix:e.jsx(d,{className:"site-form-item-icon"}),placeholder:s("account.passwordConfirm")})}),e.jsx(r.Item,{children:e.jsx(l,{type:"primary",htmlType:"submit",className:"w-full",loading:o.isPending,children:s("account.register")})}),e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-gray-600",children:s("account.haveAccount")}),e.jsx(l,{type:"link",className:"",size:"small",href:"/login",children:s("account.loginNow")})]}),e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(j,{})})]})]})})};export{R as component};
