1import{u as j,r as u,j as e,c as b,a as g}from"./main-Bo0oayNO.js";import{S as w}from"./SetupLayout-CdfExr2y.js";import{i as v,a as y}from"./index-ThM9GGfP.js";function F(){const i=j(),[m,d]=u.useState(!1),[c,o]=u.useState(null),[s,t]=u.useState({}),[a,h]=u.useState({username:"",email:"",password:"",confirmPassword:"",firstName:"",lastName:""}),n=r=>{const{name:l,value:N}=r.target;h(p=>({...p,[l]:N})),s[l]&&t(p=>({...p,[l]:""}))},x=()=>{const r={};return a.username?v(a.username)||(r.username="Username must be 3-30 characters, alphanumeric with underscores/hyphens"):r.username="Username is required",a.email?y(a.email)||(r.email="Please enter a valid email address"):r.email="Email is required",a.password?a.password.length<8&&(r.password="Password must be at least 8 characters"):r.password="Password is required",a.password!==a.confirmPassword&&(r.confirmPassword="Passwords do not match"),t(r),Object.keys(r).length===0},f=async r=>{if(r.preventDefault(),!!x()){d(!0),o(null);try{const l=await b({data:{username:a.username,email:a.email,password:a.password,firstName:a.firstName||void 0,lastName:a.lastName||void 0}});if(!l.success){o(l.error||"Failed to create admin account");return}await g(),i({to:"/setup/complete"})}catch(l){o(l instanceof Error?l.message:"Failed to create admin account")}finally{d(!1)}}};return e.jsx(w,{currentStep:3,totalSteps:4,title:"Create Admin Account",description:"Set up your administrator account to manage your site.",children:e.jsxs("form",{onSubmit:f,className:"space-y-6",children:[c&&e.jsx("div",{className:"bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg text-sm",children:c}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"firstName",className:"label",children:"First Name"}),e.jsx("input",{type:"text",id:"firstName",name:"firstName",value:a.firstName,onChange:n,className:"input",placeholder:"John"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"lastName",className:"label",children:"Last Name"}),e.jsx("input",{type:"text",id:"lastName",name:"lastName",value:a.lastName,onChange:n,className:"input",placeholder:"Doe"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"username",className:"label",children:["Username ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",id:"username",name:"username",value:a.username,onChange:n,required:!0,className:`input ${s.username?"border-red-500":""}`,placeholder:"admin"}),s.username&&e.jsx("p",{className:"form-error",children:s.username})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"email",className:"label",children:["Email ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"email",id:"email",name:"email",value:a.email,onChange:n,required:!0,className:`input ${s.email?"border-red-500":""}`,placeholder:"[email protected]"}),s.email&&e.jsx("p",{className:"form-error",children:s.email})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"password",className:"label",children:["Password ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"password",id:"password",name:"password",value:a.password,onChange:n,required:!0,className:`input ${s.password?"border-red-500":""}`,placeholder:"Min. 8 characters"}),s.password&&e.jsx("p",{className:"form-error",children:s.password}),e.jsx("div",{className:"mt-2",children:e.jsx(P,{password:a.password})})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"confirmPassword",className:"label",children:["Confirm Password ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"password",id:"confirmPassword",name:"confirmPassword",value:a.confirmPassword,onChange:n,required:!0,className:`input ${s.confirmPassword?"border-red-500":""}`,placeholder:"Repeat password"}),s.confirmPassword&&e.jsx("p",{className:"form-error",children:s.confirmPassword})]}),e.jsxs("div",{className:"flex justify-between pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>i({to:"/setup/site"}),className:"btn-secondary",children:[e.jsx("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),"Back"]}),e.jsxs("button",{type:"submit",disabled:m,className:"btn-primary",children:[m?"Creating Account...":"Install StackPress",e.jsx("svg",{className:"w-4 h-4 ml-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]})]})]})})}function P({password:i}){const m=s=>{if(!s)return{level:0,label:"",color:"bg-gray-200"};let t=0;return s.length>=8&&t++,s.length>=12&&t++,/[A-Z]/.test(s)&&t++,/[a-z]/.test(s)&&t++,/[0-9]/.test(s)&&t++,/[^A-Za-z0-9]/.test(s)&&t++,t<=2?{level:1,label:"Weak",color:"bg-red-500"}:t<=4?{level:2,label:"Medium",color:"bg-yellow-500"}:{level:3,label:"Strong",color:"bg-green-500"}},{level:d,label:c,color:o}=m(i);return i?e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"flex gap-1",children:[1,2,3].map(s=>e.jsx("div",{className:`h-1 flex-1 rounded-full ${s<=d?o:"bg-gray-200"}`},s))}),e.jsx("p",{className:"text-xs text-gray-500",children:c})]}):null}export{F as component};
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.