import{d as s}from"./chunk-TY33ZR3E.js";import{a as e}from"./chunk-OC3NYLOT.js";import"./chunk-UNITEU6O.js";var c="http://127.0.0.1:9000";function v(){let l=s(""),u=s(""),r=s(null),o=s(null),t=s(!1);async function i(n){if(n.preventDefault(),r.value=null,o.value=null,t.value=!0,!l.value.trim()||!u.value.trim()){r.value="Username and password are required.",t.value=!1;return}try{let a=await fetch(`${c}/users/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:l.value,password:u.value})});if(!a.ok){let d=await a.json().catch(()=>({detail:`HTTP error! Status: ${a.status}`}));throw new Error(d.detail||`Registration failed. Status: ${a.status}`)}o.value="Registration successful! You can now log in.",l.value="",u.value=""}catch(a){r.value=a instanceof Error?a.message:"An unexpected error occurred."}finally{t.value=!1}}return e("form",{onSubmit:i,class:"w-full max-w-sm bg-white p-6 rounded-lg shadow-md my-4",children:[e("h2",{class:"text-xl font-semibold mb-4 text-gray-700",children:"Register"}),r.value&&e("p",{class:"text-red-500 text-sm mb-3",children:r.value}),o.value&&e("p",{class:"text-green-500 text-sm mb-3",children:o.value}),e("div",{class:"mb-4",children:e("input",{type:"text",placeholder:"Username",value:l.value,onInput:n=>l.value=n.target.value,class:"input input-bordered w-full",disabled:t.value})}),e("div",{class:"mb-4",children:e("input",{type:"password",placeholder:"Password",value:u.value,onInput:n=>u.value=n.target.value,class:"input input-bordered w-full",disabled:t.value})}),e("button",{type:"submit",class:"btn btn-primary w-full",disabled:t.value,children:t.value?"Registering...":"Register"})]})}export{v as default};
