(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,89954,e=>{"use strict";var n=e.i(43476),s=e.i(71645);e.s(["default",0,function(){let[e,a]=(0,s.useState)(""),[t,i]=(0,s.useState)(""),[l,r]=(0,s.useState)(""),[o,c]=(0,s.useState)(!1),[d,h]=(0,s.useState)(!0);(0,s.useEffect)(()=>{let e=!1;return fetch("/api/auth",{cache:"no-store"}).then(e=>e.json()).then(n=>{e||(n.user&&n.landing?window.location.replace(n.landing):h(!1))}).catch(()=>!e&&h(!1)),()=>{e=!0}},[]);let u=async n=>{n.preventDefault(),c(!0),r("");try{let n=await fetch("/api/auth",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"login",email:e,password:t})}),s=await n.json();if(!n.ok)throw Error(s.error||"Unable to sign in");window.location.replace(s.landing||"/")}catch(e){r(e instanceof Error?e.message:"Unable to sign in"),c(!1)}};return d?(0,n.jsx)("div",{className:"login-shell",children:(0,n.jsx)("div",{className:"login-card",children:(0,n.jsx)("p",{className:"login-checking",children:"Checking your session..."})})}):(0,n.jsx)("div",{className:"login-shell",children:(0,n.jsxs)("div",{className:"login-card",children:[(0,n.jsxs)("div",{className:"login-brand",children:[(0,n.jsx)("span",{className:"brand-mark",children:"HO"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"Hostel Operations"}),(0,n.jsx)("small",{children:"Internal management system"})]})]}),(0,n.jsx)("h1",{children:"Sign in"}),(0,n.jsx)("p",{className:"login-intro",children:"Staff accounts open the management system. Student accounts open the resident portal."}),l&&(0,n.jsx)("div",{className:"login-error",children:l}),(0,n.jsxs)("form",{onSubmit:u,children:[(0,n.jsxs)("label",{children:["Email",(0,n.jsx)("input",{type:"email",value:e,onChange:e=>a(e.target.value),autoComplete:"username",required:!0,autoFocus:!0})]}),(0,n.jsxs)("label",{children:["Password",(0,n.jsx)("input",{type:"password",value:t,onChange:e=>i(e.target.value),autoComplete:"current-password",required:!0})]}),(0,n.jsx)("button",{className:"primary",disabled:o,children:o?"Signing in...":"Sign in"})]}),(0,n.jsx)("p",{className:"login-foot",children:"Forgot your password? Ask an administrator to set a new one for you."})]})})}])}]);