1import{r as t,i as R,b as E,k as $,j as e,H as G,L as f,t as r}from"./index-ab38db77.js";import{c as q,r as M}from"./authRedirect-9431f409.js";import{B as v}from"./button-aceb6222.js";import{I as l}from"./input-88a8d561.js";import{L as n}from"./label-e649a24b.js";import{A as D}from"./arrow-left-78cc89c4.js";import{B as I}from"./bot-f88ad613.js";import{L as y}from"./loader-2-1b0f84cc.js";import"./index-38ea8514.js";import"./createLucideIcon-350a23d4.js";const Y=()=>{const[d,j]=t.useState(""),[m,w]=t.useState(""),[i,N]=t.useState(""),[c,C]=t.useState(""),[o,u]=t.useState(null),[h,x]=t.useState(!1),[g,b]=t.useState(!1),{signup:A,loginWithGoogle:k}=R(),S=E(),p=$(),L=async s=>{if(!s||s.length<3){u(null);return}try{const P=await(await fetch(`/api/auth/check-username?username=${s}`)).json();u(P.available)}catch(a){console.error(a)}},H=s=>{const a=s.target.value.toLowerCase().replace(/[^a-z0-9_]/g,"");w(a),L(a)},U=s=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s),z=s=>/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/.test(s),B=async s=>{if(s.preventDefault(),!U(i)){r.error("Please enter a valid email address");return}if(!z(c)){r.error("Password must be at least 8 characters long and contain at least one uppercase letter, one lowercase letter, one number, and one special character");return}if(o===!1){r.error("Username is already taken");return}x(!0);try{const a=await A(d,i,c,m);a.success?(r.success("Account created successfully! Logging you in..."),setTimeout(()=>{S(q(p.search))},500)):r.error(a.error||"Signup failed. Please try again.")}catch(a){console.error("Signup error:",a),r.error("An unexpected error occurred.")}finally{x(!1)}},F=async()=>{b(!0);try{M(new URLSearchParams(p.search).get("redirect")||""),await k()}catch{r.error("Failed to connect to Google"),b(!1)}};return e.jsxs("div",{className:"min-h-screen flex items-center justify-center p-4 relative overflow-hidden bg-gradient-to-br from-white via-sky-50/70 to-emerald-50/60",children:[e.jsxs(G,{children:[e.jsx("title",{children:"Sign Up | RoboCloud Hub"}),e.jsx("meta",{name:"description",content:"Create an account on RoboCloud Hub to start learning robotics, tracking your progress, and connecting with experts."}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"}),e.jsx("link",{rel:"canonical",href:"https://robocloud-dashboard.vercel.app/signup"})]}),e.jsxs("div",{className:"w-full max-w-md relative z-10",children:[e.jsxs(f,{to:"/",className:"inline-flex items-center gap-2 text-sm font-semibold text-gray-500 hover:text-blue-600 transition-colors mb-6 group",children:[e.jsx(D,{className:"w-4 h-4 group-hover:-translate-x-1 transition-transform"}),e.jsx("span",{children:"Back to Home"})]}),e.jsxs("div",{className:"bg-white p-8 rounded-2xl border border-blue-100 shadow-sm",children:[e.jsxs("div",{className:"flex flex-col items-center mb-8",children:[e.jsx("div",{className:"p-3 bg-blue-600 rounded-xl shadow-sm mb-5",children:e.jsx(I,{className:"w-8 h-8 text-white"})}),e.jsx("h1",{className:"text-2xl font-extrabold text-gray-900 mb-2",children:"Create Account"}),e.jsx("p",{className:"text-gray-500 text-center text-sm",children:"Join the RoboCloud Hub community today"})]}),e.jsxs(v,{type:"button",variant:"outline",className:"w-full mb-6 bg-white hover:bg-gray-50 text-gray-700 border-gray-200 h-11 text-sm font-semibold shadow-sm",onClick:F,disabled:g,children:[g?e.jsx(y,{className:"w-4 h-4 animate-spin mr-2"}):e.jsxs("svg",{className:"w-5 h-5 mr-2",viewBox:"0 0 24 24",children:[e.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),e.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),e.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),e.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),"Continue with Google"]}),e.jsxs("div",{className:"relative mb-6",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-gray-200"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-widest",children:e.jsx("span",{className:"bg-white px-4 text-gray-400 font-semibold",children:"Or continue with email"})})]}),e.jsxs("form",{onSubmit:B,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"name",className:"text-xs uppercase tracking-wider text-gray-500 font-bold ml-1",children:"Full Name"}),e.jsx(l,{id:"name",placeholder:"John Doe",value:d,onChange:s=>j(s.target.value),required:!0,className:"bg-white border-gray-200 focus:border-blue-400 focus-visible:ring-blue-500/10 text-gray-900 placeholder-gray-400 h-11 rounded-lg transition-colors"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"username",className:"text-xs uppercase tracking-wider text-gray-500 font-bold ml-1",children:"Username"}),e.jsxs("div",{className:"relative",children:[e.jsx(l,{id:"username",placeholder:"johndoe",value:m,onChange:H,required:!0,className:`bg-white border-gray-200 focus:border-blue-400 focus-visible:ring-blue-500/10 text-gray-900 placeholder-gray-400 h-11 rounded-lg transition-colors pr-20 ${o===!0?"border-green-400":o===!1?"border-red-400":""}`}),o===!0&&e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-xs text-green-600 font-bold",children:"Available"}),o===!1&&e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-xs text-red-600 font-bold",children:"Taken"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"email",className:"text-xs uppercase tracking-wider text-gray-500 font-bold ml-1",children:"Email"}),e.jsx(l,{id:"email",type:"email",placeholder:"[email protected]",value:i,onChange:s=>N(s.target.value),required:!0,className:"bg-white border-gray-200 focus:border-blue-400 focus-visible:ring-blue-500/10 text-gray-900 placeholder-gray-400 h-11 rounded-lg transition-colors"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"password",className:"text-xs uppercase tracking-wider text-gray-500 font-bold ml-1",children:"Password"}),e.jsx(l,{id:"password",type:"password",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",value:c,onChange:s=>C(s.target.value),required:!0,className:"bg-white border-gray-200 focus:border-blue-400 focus-visible:ring-blue-500/10 text-gray-900 placeholder-gray-400 h-11 rounded-lg transition-colors"})]}),e.jsx(v,{type:"submit",className:"w-full bg-blue-600 hover:bg-blue-700 text-white shadow-sm shadow-blue-600/20 hover:shadow-md h-11 rounded-lg text-sm font-bold transition-all mt-2 disabled:opacity-50 disabled:cursor-not-allowed",disabled:h||o===!1,children:h?e.jsx(y,{className:"w-4 h-4 animate-spin"}):"Create Account"})]}),e.jsxs("div",{className:"mt-6 text-center text-sm text-gray-500",children:["Already have an account?"," ",e.jsx(f,{to:"/login",className:"text-blue-600 hover:text-blue-700 font-bold transition-colors hover:underline",children:"Sign in"})]})]})]})]})};export{Y as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.