1import{x as P,r,y as l,j as e,Y as g,g as R,w as A,L as f,A as c,Q as b,q as p}from"./index-D-ZsJRgs.js";import{E as C}from"./eye-off-ut2PA3xi.js";import{E as L}from"./eye-Clj-3VPG.js";function q(){const w=P(),[a,j]=r.useState(""),[m,N]=r.useState(""),[n,v]=r.useState(!1),[d,x]=r.useState(!1),[y,k]=r.useState(!1),[u,o]=r.useState(""),[i,h]=r.useState(null);r.useEffect(()=>{const{data:{subscription:s}}=l.auth.onAuthStateChange(t=>{t==="PASSWORD_RECOVERY"&&h(!0)});return l.auth.getSession().then(({data:{session:t}})=>{h(E=>E===!0?!0:!!t)}),()=>s.unsubscribe()},[]);async function S(s){if(s.preventDefault(),!a){o("Please enter a new password.");return}if(a.length<8){o("Password must be at least 8 characters.");return}if(a!==m){o("Passwords do not match.");return}o(""),x(!0);const{error:t}=await l.auth.updateUser({password:a});if(t){o(t.message);try{await l.from("admin_error_log").insert({error_type:"ADMIN_PASSWORD_RESET_FAILED",error_message:t.message,metadata:{code:t.status??null,timestamp:new Date().toISOString()},request_url:"/admin/reset-password"})}catch{}}else k(!0),l.auth.signOut(),setTimeout(()=>w("/admin/login"),3e3);x(!1)}return i===null?e.jsx("div",{className:"min-h-screen bg-dark-950 flex items-center justify-center",children:e.jsx(g,{className:"w-6 h-6 text-gold-400 animate-spin"})}):e.jsxs("div",{className:"min-h-screen bg-dark-950 flex flex-col items-center justify-center px-4",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute -top-40 -right-40 w-96 h-96 bg-gold-400/5 rounded-full blur-3xl"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-96 h-96 bg-primary-600/5 rounded-full blur-3xl"})]}),e.jsxs("div",{className:"relative w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-gradient-to-br from-gold-400 to-gold-600 shadow-lg shadow-gold-400/20 mb-4",children:e.jsx(R,{className:"w-8 h-8 text-white"})}),e.jsx("h1",{className:"text-2xl font-bold text-white tracking-tight",children:"Set New Password"}),e.jsx("p",{className:"text-dark-400 text-sm mt-1",children:i?"Choose a strong new password for your admin account.":"This reset link is invalid or has expired."})]}),e.jsx("div",{className:"bg-dark-900 border border-dark-700 rounded-2xl p-8 shadow-2xl",children:y?e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-success-500/15 border border-success-500/30 flex items-center justify-center mx-auto mb-4",children:e.jsx(A,{className:"w-7 h-7 text-success-400"})}),e.jsx("h2",{className:"text-lg font-bold text-white mb-2",children:"Password Updated"}),e.jsx("p",{className:"text-dark-400 text-sm mb-6",children:"Your admin password has been changed. Redirecting to login..."}),e.jsxs(f,{to:"/admin/login",className:"w-full flex items-center justify-center gap-2 py-3 px-4 bg-gradient-to-r from-gold-500 to-gold-600 text-white font-semibold rounded-xl text-sm hover:from-gold-400 hover:to-gold-500 transition-all",children:["Go to Admin Login ",e.jsx(c,{className:"w-4 h-4"})]})]}):i?e.jsxs("form",{onSubmit:S,className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-dark-200 mb-1.5",children:"New Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(p,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-dark-500"}),e.jsx("input",{type:n?"text":"password",value:a,onChange:s=>j(s.target.value),placeholder:"At least 8 characters",required:!0,autoFocus:!0,disabled:d,className:"w-full pl-10 pr-11 py-3 bg-dark-800 border border-dark-600 rounded-xl text-white placeholder-dark-500 text-sm focus:outline-none focus:ring-2 focus:ring-gold-400/50 focus:border-gold-400/50 transition-all disabled:opacity-50"}),e.jsx("button",{type:"button",onClick:()=>v(s=>!s),className:"absolute right-3 top-1/2 -translate-y-1/2 text-dark-500 hover:text-dark-300 transition-colors",tabIndex:-1,children:n?e.jsx(C,{className:"w-4 h-4"}):e.jsx(L,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-dark-200 mb-1.5",children:"Confirm New Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(p,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-dark-500"}),e.jsx("input",{type:n?"text":"password",value:m,onChange:s=>N(s.target.value),placeholder:"Re-enter your new password",required:!0,disabled:d,className:"w-full pl-10 pr-4 py-3 bg-dark-800 border border-dark-600 rounded-xl text-white placeholder-dark-500 text-sm focus:outline-none focus:ring-2 focus:ring-gold-400/50 focus:border-gold-400/50 transition-all disabled:opacity-50"})]})]}),u&&e.jsxs("div",{className:"flex items-start gap-2.5 bg-error-950/60 border border-error-800/60 rounded-xl px-4 py-3",children:[e.jsx(b,{className:"w-4 h-4 text-error-400 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-error-300",children:u})]}),e.jsx("button",{type:"submit",disabled:d,className:"w-full flex items-center justify-center gap-2 py-3 px-4 bg-gradient-to-r from-gold-500 to-gold-600 text-white font-semibold rounded-xl text-sm hover:from-gold-400 hover:to-gold-500 transition-all focus:outline-none focus:ring-2 focus:ring-gold-400/50 disabled:opacity-50 disabled:cursor-not-allowed shadow-lg shadow-gold-400/20",children:d?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"w-4 h-4 animate-spin"})," Updating..."]}):e.jsxs(e.Fragment,{children:["Update Password ",e.jsx(c,{className:"w-4 h-4"})]})})]}):e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"w-14 h-14 roun
1ded-full bg-error-950/60 border border-error-800/60 flex items-center justify-center mx-auto mb-4",children:e.jsx(b,{className:"w-7 h-7 text-error-400"})}),e.jsx("h2",{className:"text-lg font-bold text-white mb-2",children:"Link Expired"}),e.jsx("p",{className:"text-dark-400 text-sm mb-6",children:"This password reset link is no longer valid. Reset links expire after 1 hour."}),e.jsxs(f,{to:"/admin/forgot-password",className:"w-full flex items-center justify-center gap-2 py-3 px-4 bg-gradient-to-r from-gold-500 to-gold-600 text-white font-semibold rounded-xl text-sm hover:from-gold-400 hover:to-gold-500 transition-all",children:["Request New Link ",e.jsx(c,{className:"w-4 h-4"})]})]})})]})]})}export{q as default};
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.