1"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[6710],{23385(e,t,s){s.r(t),s.d(t,{component:()=>k});var n=s(72361),r=s(71114),i=s(6702),a=s(74657),o=s(68413),c=s(86832),l=s(48367),d=s(20598),u=s(20032),x=s(81204),m=s(46775),p=s(23780),f=s(97077),h=s(54023),j=s(72982),g=s(16272),N=s(88901),b=s(17720),v=s(22509);function y(e){let{className:t,...s}=e,{t:r}=(0,i.Bd)(),[a,y]=(0,o.useState)(!1),[k,C]=(0,o.useState)(!1),{auth:V}=(0,u.n)(),{redirectToLogin:w}=(0,b.u)(),R=(0,c.mN)({resolver:(0,l.u)(N.bg),defaultValues:{otp:""}}),X=R.watch("otp");async function F(e){var t,s;if(k){if(t=e.otp,!N.RW.test(t))return void d.oR.error(r("Backup code must be in format XXXX-XXXX"))}else if(s=e.otp,!N.eX.test(s))return void d.oR.error(r("Verification code must be 6 digits"));y(!0);try{let t=k?e.otp.replace(/-/g,""):e.otp,s=await (0,g.li)({code:t});if(!s.success)return void d.oR.error(s.message||r("Invalid code"));let n=s.data;if(!n)throw Error("No user data received from login");V.setUser(n),n.id&&(0,v.cq)(n.id),d.oR.success(r("Signed in")),w()}catch(t){console.error("2FA verification error:",t);let e=t instanceof Error?t.message:r("Verification failed");d.oR.error(e)}finally{y(!1)}}let S=k?X.length>=9:X.length>=6;return(0,n.jsx)(f.lV,{...R,children:(0,n.jsxs)("form",{onSubmit:R.handleSubmit(F),className:(0,x.cn)("grid gap-4",t),...s,children:[(0,n.jsx)(f.zB,{control:R.control,name:"otp",render:e=>{let{field:t}=e;return(0,n.jsxs)(f.eI,{children:[(0,n.jsx)(f.lR,{children:k?r("Backup Code"):r("Verification Code")}),(0,n.jsx)(f.MJ,{children:k?(0,n.jsx)(h.p,{placeholder:r("Enter backup code (e.g., CAWD-OQDV)"),...t,maxLength:9,autoComplete:"off",className:"font-mono uppercase",onChange:e=>{let s,n=((s=e.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")).length>8&&(s=s.slice(0,8)),s.length>4)?s.slice(0,4)+"-"+s.slice(4):s;t.onChange(n)}}):(0,n.jsxs)(j.UV,{maxLength:6,...t,containerClassName:'justify-between sm:[&>[data-slot="input-otp-group"]>div]:w-12',children:[(0,n.jsxs)(j.NV,{children:[(0,n.jsx)(j.sF,{index:0}),(0,n.jsx)(j.sF,{index:1})]}),(0,n.jsx)(j.pf,{}),(0,n.jsxs)(j.NV,{children:[(0,n.jsx)(j.sF,{index:2}),(0,n.jsx)(j.sF,{index:3})]}),(0,n.jsx)(j.pf,{}),(0,n.jsxs)(j.NV,{children:[(0,n.jsx)(j.sF,{index:4}),(0,n.jsx)(j.sF,{index:5})]})]})}),(0,n.jsx)(f.Rr,{className:"text-muted-foreground text-xs",children:k?r("Each backup code can only be used once."):r("Verification code updates every 30 seconds.")}),(0,n.jsx)(f.C5,{})]})}}),(0,n.jsx)(p.o,{type:"submit",size:"lg",loading:a,className:"mt-2 w-full justify-center",disabled:!S||a,children:r("Verify and Sign In")}),(0,n.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm",children:[(0,n.jsx)(m.$,{type:"button",variant:"link",size:"sm",className:"text-primary h-auto p-0",onClick:function(){C(!k),R.setValue("otp","")},children:k?r("Use authenticator code"):r("Use backup code")}),(0,n.jsx)("span",{className:"text-muted-foreground",children:"·"}),(0,n.jsx)(m.$,{type:"button",variant:"link",size:"sm",className:"text-primary h-auto p-0",onClick:function(){w()},children:r("Back to login")})]})]})})}let k=function(){let{t:e}=(0,i.Bd)();return(0,n.jsx)(a.D,{children:(0,n.jsxs)("div",{className:"w-full space-y-8",children:[(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsx)("h2",{className:"text-center text-2xl font-semibold tracking-tight sm:text-left",children:e("Two-factor Authentication")}),(0,n.jsx)("p",{className:"text-muted-foreground text-left text-sm sm:text-base",children:e("Please enter the authentication code.")}),(0,n.jsxs)("p",{className:"text-muted-foreground text-left text-sm sm:text-base",children:[e("Session expired?")," ",(0,n.jsx)(r.N_,{to:"/sign-in",className:"hover:text-primary font-medium underline underline-offset-4",children:e("Re-login")}),"."]})]}),(0,n.jsx)(y,{})]})})}}}]);
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.