(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,94887,e=>{"use strict";var t=e.i(22152),a=e.i(2732),s=e.i(52313),o=e.i(28175);let r=t.default.env.NEXT_PUBLIC_API_BASE||"http://localhost:5000";function l(){let e=(0,o.useRouter)(),t=(0,o.useSearchParams)(),[l,n]=(0,s.useState)("admin");(0,s.useEffect)(()=>{let e=t.get("username");e&&n(String(e))},[t]);let[i,d]=(0,s.useState)(""),[c,m]=(0,s.useState)(""),[u,h]=(0,s.useState)(!1),p=async t=>{t.preventDefault(),m(""),h(!0);try{let t=await fetch(`${r}/api/admin/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:l,password:i})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.message||"Login failed")}let a=await t.json(),s=a?.token||"";if(!s)throw Error("Token missing from server");localStorage.setItem("admin_token_v1",s),localStorage.setItem("admin_session_v1","true"),document.cookie=`admin_token_v1=${encodeURIComponent(s)}; path=/`,document.cookie="admin_session_v1=true; path=/",e.replace("/admin/inbox")}catch(e){m(e?.message||"Login failed")}finally{h(!1)}};return(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-[#f6f6f6] p-6",children:(0,a.jsxs)("div",{className:"w-full max-w-md bg-white border border-black/10 rounded-2xl shadow-sm p-6",children:[(0,a.jsx)("div",{className:"text-2xl font-bold",children:"Admin Login"}),(0,a.jsx)("div",{className:"text-xs text-gray-500 mt-1",children:"Social AI Bot"}),(0,a.jsxs)("form",{onSubmit:p,className:"mt-6 space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-sm font-semibold mb-1",children:"Username"}),(0,a.jsx)("input",{value:l,onChange:e=>n(e.target.value),className:"w-full px-4 py-3 rounded-lg border border-black/10",placeholder:"username",autoComplete:"username"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-sm font-semibold mb-1",children:"Password"}),(0,a.jsx)("input",{type:"password",value:i,onChange:e=>d(e.target.value),className:"w-full px-4 py-3 rounded-lg border border-black/10",placeholder:"password",autoComplete:"current-password"})]}),c?(0,a.jsx)("div",{className:"text-sm text-red-600",children:c}):null,(0,a.jsx)("button",{disabled:u,className:"w-full px-4 py-3 rounded-lg border border-black/10 hover:bg-black hover:text-white transition disabled:opacity-60",children:u?"Logging in...":"Login"})]})]})})}e.s(["default",()=>l])}]);