(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,75023,e=>{"use strict";var t=e.i(22152),s=e.i(2732),r=e.i(52313),a=e.i(28175);let i=t.default.env.NEXT_PUBLIC_API_BASE||"http://localhost:5000";async function l(e){try{let t=await e.json();return String(t?.message||e.statusText)}catch{return String(e.statusText||"Request failed")}}function o(){let e=(0,a.useSearchParams)(),t=(0,a.useRouter)(),o=(0,r.useMemo)(()=>String(e.get("token")||""),[e]),[n,d]=(0,r.useState)(""),[c,u]=(0,r.useState)(""),[m,p]=(0,r.useState)(!1),[h,g]=(0,r.useState)(""),[b,x]=(0,r.useState)("");(0,r.useEffect)(()=>{o||g("Missing invite token")},[o]);let w=async()=>{if(g(""),x(""),!o)return g("Missing invite token");if(!n)return g("Password is required");if(n!==c)return g("Passwords do not match");p(!0);try{let e=await fetch(`${i}/api/admin/accept-invite`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:o,password:n})});if(!e.ok)throw Error(await l(e));let s=await e.json();x("Password set successfully. Redirecting to login...");let r=encodeURIComponent(String(s?.email||""));setTimeout(()=>{t.replace(`/admin/login?username=${r}`)},800)}catch(e){g(e?.message||"Failed to set password")}finally{p(!1)}};return(0,s.jsx)("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center p-4",children:(0,s.jsxs)("div",{className:"w-full max-w-md bg-white border border-black/10 rounded-xl p-5",children:[(0,s.jsx)("div",{className:"text-xl font-bold",children:"Set your password"}),(0,s.jsx)("div",{className:"text-xs text-gray-500 mt-1",children:"This invite link expires after a short time. Choose a strong password."}),h?(0,s.jsx)("div",{className:"mt-3 p-3 border border-red-200 bg-red-50 rounded-lg text-red-700 text-sm",children:h}):null,b?(0,s.jsx)("div",{className:"mt-3 p-3 border border-emerald-200 bg-emerald-50 rounded-lg text-emerald-700 text-sm",children:b}):null,(0,s.jsxs)("div",{className:"mt-4 space-y-3",children:[(0,s.jsx)("input",{value:n,onChange:e=>d(e.target.value),type:"password",placeholder:"New password (10+ chars, upper/lower/number/symbol)",className:"w-full px-3 py-2 rounded-lg border border-black/10"}),(0,s.jsx)("input",{value:c,onChange:e=>u(e.target.value),type:"password",placeholder:"Confirm password",className:"w-full px-3 py-2 rounded-lg border border-black/10"}),(0,s.jsx)("button",{onClick:w,disabled:m,className:"w-full px-4 py-2 rounded-lg border border-black/10 hover:bg-black hover:text-white transition disabled:opacity-50",children:m?"Saving...":"Save password"}),(0,s.jsx)("div",{className:"text-xs text-gray-500",children:"Tip: Use a password manager. Strong password = 10+ chars with upper, lower, number, and symbol."})]})]})})}e.s(["default",()=>o])}]);