1import{j as e}from"./vendor-markdown-3uENCkuS.js";import{d as B,r as m}from"./vendor-react-router-fbnoKto0.js";import{e as j}from"./examAdminService-DKMZxThm.js";import{a5 as b,dW as R,am as y,dX as T,an as C,ay as P,aa as E,G as O}from"./vendor-icons-kV6MQrcF.js";import"./vendor-react-dom-CekZHfxh.js";import"./index-zslOFxNg.js";import"./vendor-antd-CYdTsTmT.js";import"./vendor-reactflow-CEYCdEGm.js";import"./vendor-recharts-DJYAw1LN.js";import"./vendor-redux-8frB-79w.js";import"./vendor-syntax-highlighter-1lJlPebH.js";const A="/admin/exam-admin/tenants",v=({onComplete:u,disabled:r,error:f})=>{const[n,o]=m.useState(["","","","","",""]),i=m.useRef([]);m.useEffect(()=>{setTimeout(()=>{var t;return(t=i.current[0])==null?void 0:t.focus()},200)},[]);const d=(t,s)=>{var h;const a=s.replace(/\D/g,"").slice(-1),x=[...n];if(x[t]=a,o(x),a&&t<5&&((h=i.current[t+1])==null||h.focus()),a&&t===5){const g=x.join("");g.length===6&&u(g)}},N=(t,s)=>{var a;if(s.key==="Backspace"&&!n[t]&&t>0&&((a=i.current[t-1])==null||a.focus()),s.key==="Enter"){const x=n.join("");x.length===6&&u(x)}},w=t=>{var x;t.preventDefault();const s=t.clipboardData.getData("text").replace(/\D/g,"").slice(0,6);if(!s)return;const a=[...n];for(let h=0;h<s.length;h++)a[h]=s[h];o(a),(x=i.current[Math.min(s.length,5)])==null||x.focus(),s.length===6&&u(s)};return m.useEffect(()=>{o(["","","","","",""]),setTimeout(()=>{var t;return(t=i.current[0])==null?void 0:t.focus()},200)},[r]),e.jsx("div",{className:"flex items-center gap-2.5",onPaste:w,children:n.map((t,s)=>e.jsx("input",{ref:a=>i.current[s]=a,type:"text",inputMode:"numeric",maxLength:1,value:t,onChange:a=>d(s,a.target.value),onKeyDown:a=>N(s,a),className:`w-12 h-14 text-center text-2xl font-semibold rounded-xl border-2 outline-none transition-all ${f?"border-red-300 bg-red-50/30 focus:border-red-500 focus:ring-2 focus:ring-red-100":"border-[#D5D7DA] bg-white focus:border-[#2333CB] focus:ring-2 focus:ring-[#D3D6F5]"}`,disabled:r},s))})},$=()=>{const u=B(),[r,f]=m.useState("choose"),[n,o]=m.useState(!1),[i,d]=m.useState(null),[N,w]=m.useState(""),[t,s]=m.useState(null),[a,x]=m.useState(!1);m.useEffect(()=>{if(r==="done"){const l=setTimeout(()=>{u(A)},2e3);return()=>clearTimeout(l)}},[r,u]);const h=()=>{t!=null&&t.secret&&(navigator.clipboard.writeText(t.secret),x(!0),setTimeout(()=>x(!1),2e3))},g=async()=>{var l;o(!0),d(null);try{const c=await j.post("/api/v1/auth/2fa/reconfigure/send-otp");w(((l=c==null?void 0:c.data)==null?void 0:l.message)||"OTP sent to your registered email."),f("otp")}catch(c){d((c==null?void 0:c.message)||"Failed to send OTP.")}finally{o(!1)}},D=async(l,c)=>{o(!0),d(null);try{const p=c==="otp"?{otp:l}:{code:l},F=await j.post("/api/v1/auth/2fa/reconfigure",p);s((F==null?void 0:F.data)||null),f("scan")}catch(p){d((p==null?void 0:p.message)||"Reconfiguration failed.")}finally{o(!1)}},S=async l=>{if(!(t!=null&&t.secret)){d("Setup data missing. Please try again.");return}o(!0),d(null);try{await j.post("/api/v1/auth/2fa/enable",{code:l,secret:t.secret}),f("done")}catch(c){d((c==null?void 0:c.message)||"Failed to enable new 2FA.")}finally{o(!1)}},k=async()=>{o(!0),d(null);try{await j.delete("/api/v1/auth/2fa/reset");try{sessionStorage.removeItem("2fa_session_token"),sessionStorage.removeItem("2fa_page_verified")}catch{}u(A)}catch(l){d((l==null?void 0:l.message)||"Failed to reset 2FA.")}finally{o(!1)}};return e.jsx("div",{className:"flex flex-col items-center justify-center w-full min-h-screen bg-[#FAFAFA] p-4",children:e.jsxs("div",{className:"flex flex-col items-center w-full max-w-[480px] bg-white rounded-2xl border border-[#E9EAEB] shadow-lg p-8 gap-5",children:[r==="choose"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-center w-14 h-14 bg-[#FFF6ED] border-[8px] border-[#FFFAEB] rounded-full",children:e.jsx(b,{className:"h-6 w-6 text-[#EF6820]"})}),e.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[e.jsx("h1",{className:"text-lg font-semibold text-[#181D27]",children:"2FA Reconfigure / Reset"}),e.jsx("p",{className:"text-sm text-[#535862] leading-5",children:"Choose how to proceed based on your current access."})]}),e.jsxs("div",{className:"flex flex-col gap-3 w-full",children:[e.jsxs("button",{onClick:()=>f("code"),className:"w-full h-12 flex items-center justify-center gap-2 bg-[#2333CB] border border-[#4F5CD5] rounded-xl text-sm font-semibold text-white hover:bg-[#1a26a3] transition-all shadow-sm",children:[e.jsx(R,{className:"h-4 w-4"}),"I have my old device"]}),e.jsxs("button",{onClick:g,disabled:n,className:"w-full h-12 flex items-center justify-center gap-2 bg-white border border-[#D5D7DA] rounded-xl text-sm font-semibold text-[#414651] hover:bg-[#F9FAFB] transition-all disabled:opacity-50",children:[n?e.jsx(b,{className:"h-4 w-4 animate-spin"}):e.jsx(y,{className:"h-4 w-4"}),"Send code to my email"]}),e.jsx("button",{onClick:()=>f("reset-confirm"),className:"w-full h-10 flex items-center justify-center text-xs font-medium text-[#D92D20] hover:underline",children:"No access at all? Force reset"})]})]}),r==="code"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-center w-14 h-14 bg-[#EEF4FF] border-[8px] border-[#F5F8FF] rounded-full",children:e.jsx(y,{className:"h-6 w-6 text-[#2333CB]"})}),e.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[e.jsx("h1",{className:"text-lg font-semibold text-[#181D27]",children:"Enter Current Code"}),e.jsx("p",{className:"text-sm text-[#535862] leading-5",children:"Enter the 6-digit code from your current authenticator app."})]}),e.jsx(v,{onComplete:l=>D(l,"code"),disabled:n,error:i})]}),r==="otp"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-center w-14 h-14 bg-[#EEF4FF] border-[8px] border-[#F5F8FF] rounded-full",children:e.jsx(y,{className:"h-6 w-6 text-[#2333CB]"})}),e.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[e.jsx("h1",{className:"text-lg font-semibold text-[#181D27]",children:"Enter Email OTP"}),e.jsx("p",{className:"text-sm text-[#535862] leading-5",children:N})]}),e.jsx(v,{onComplete:l=>D(l,"otp"),disabled:n,error:i}),e.jsx("button",{onClick:g,disabled:n,className:"text-xs font-medium text-[#2333CB] hover:underline disabled:opacity-50",children:"Resend OTP"})]}),r==="scan"&&t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-center w-14 h-14 bg-[#EEF4FF] border-[8px] border-[#F5F8FF] rounded-full",children:e.jsx(T,{className:"h-6 w-6 text-[#2333CB]"})}),e.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[e.jsx("h1",{className:"text-lg font-semibold text-[#181D27]",children:"Scan New QR Code"}),e.jsx("p",{className:"text-sm text-[#535862] leading-5",children:"Scan with your new authenticator app, then enter the code below."})]}),t.qrCode&&e.jsx("div",{className:"p-3 bg-white border-2 border-[#
1E9EAEB] rounded-xl",children:e.jsx("img",{src:t.qrCode,alt:"New 2FA QR Code",className:"w-48 h-48"})}),t.secret&&e.jsxs("div",{className:"flex items-center gap-2 w-full bg-[#F9FAFB] border border-[#E9EAEB] rounded-lg px-3 py-2.5",children:[e.jsx("span",{className:"text-xs text-[#535862] font-medium",children:"Manual key:"}),e.jsx("code",{className:"text-xs font-mono text-[#181D27] flex-1 truncate",children:t.secret}),e.jsx("button",{onClick:h,className:"p-1 text-[#717680] hover:text-[#2333CB] transition-colors",children:a?e.jsx(C,{className:"h-4 w-4 text-green-600"}):e.jsx(P,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"w-full flex flex-col items-center gap-2",children:[e.jsx("p",{className:"text-xs font-medium text-[#414651]",children:"Enter code from new device:"}),e.jsx(v,{onComplete:S,disabled:n,error:i})]})]}),r==="reset-confirm"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-center w-14 h-14 bg-[#FEF3F2] border-[8px] border-[#FEE4E2] rounded-full",children:e.jsx(E,{className:"h-6 w-6 text-[#D92D20]"})}),e.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[e.jsx("h1",{className:"text-lg font-semibold text-[#181D27]",children:"Force Reset 2FA"}),e.jsx("p",{className:"text-sm text-[#535862] leading-5",children:"This will completely remove 2FA. The user will need to set it up again from scratch."})]}),e.jsxs("div",{className:"flex flex-col gap-3 w-full",children:[e.jsxs("button",{onClick:k,disabled:n,className:"w-full h-12 flex items-center justify-center gap-2 bg-[#D92D20] border border-[#D92D20] rounded-xl text-sm font-semibold text-white hover:bg-[#B42318] transition-all shadow-sm disabled:opacity-50",children:[n?e.jsx(b,{className:"h-4 w-4 animate-spin"}):null,"Confirm Reset"]}),e.jsx("button",{onClick:()=>f("choose"),className:"w-full h-10 flex items-center justify-center text-sm font-medium text-[#414651] hover:text-[#181D27]",children:"Cancel"})]})]}),r==="done"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-center w-14 h-14 bg-[#ECFDF3] border-[8px] border-[#D1FADF] rounded-full",children:e.jsx(C,{className:"h-6 w-6 text-[#067647]"})}),e.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[e.jsx("h1",{className:"text-lg font-semibold text-[#181D27]",children:"Done"}),e.jsx("p",{className:"text-sm text-[#535862] leading-5",children:"2FA has been updated successfully. Redirecting..."})]})]}),i&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2 w-full",children:[e.jsx(E,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{children:i})]}),n&&r!=="choose"&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[#2333CB]",children:[e.jsx(b,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:"Processing..."})]}),r!=="choose"&&r!=="done"&&e.jsxs("button",{onClick:()=>{f("choose"),d(null),s(null)},className:"flex items-center gap-1 text-xs font-medium text-[#717680] hover:text-[#181D27] mt-2",children:[e.jsx(O,{className:"h-3 w-3"}),"Back"]})]})})};export{$ 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.