1"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[2137],{89806(e,t,s){s.d(t,{nc:()=>r,lW:()=>o,$e:()=>i,Rk:()=>l,pF:()=>n});var a=s(64577);async function n(){return(await a.FH.get("/api/user/passkey")).data}async function r(){return(await a.FH.post("/api/user/passkey/login/begin")).data}async function i(e){return(await a.FH.post("/api/user/passkey/login/finish",e)).data}async function o(){return(await a.FH.post("/api/user/passkey/verify/begin")).data}async function l(e){return(await a.FH.post("/api/user/passkey/verify/finish",e)).data}s(68413),s(19376),s(20598)},54369(e,t,s){function a(e){if(!e)return new ArrayBuffer(0);let t="=".repeat((4-e.length%4)%4),s=(e+t).replace(/-/g,"+").replace(/_/g,"/"),a=globalThis,n=("function"==typeof a.atob?a.atob.bind(a):e=>{if(void 0!==a.Buffer)return a.Buffer.from(e,"base64").toString("binary");throw Error("Base64 decoding is not supported in this environment")})(s),r=new ArrayBuffer(n.length),i=new Uint8Array(r);for(let e=0;e<n.length;e+=1)i[e]=n.charCodeAt(e);return r}function n(e){if(!e)return"";let t=globalThis,s=new Uint8Array(e),a="";for(let e=0;e<s.byteLength;e+=1)a+=String.fromCharCode(s[e]);return("function"==typeof t.btoa?t.btoa.bind(t):e=>{if(void 0!==t.Buffer)return t.Buffer.from(e,"binary").toString("base64");throw Error("Base64 encoding is not supported in this environment")})(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function r(e){let t=e?.publicKey??e?.PublicKey??e?.response??e?.Response;if(!t)throw Error("Unable to parse Passkey login options from response");let s={...t,challenge:a(t.challenge)};return Array.isArray(t.allowCredentials)&&(s.allowCredentials=t.allowCredentials.map(e=>({...e,id:a(e.id)}))),s}function i(e){if(!e)return null;let t=e.response;return{id:e.id,rawId:n(e.rawId),type:e.type,authenticatorAttachment:e.authenticatorAttachment,response:{authenticatorData:n(t.authenticatorData),clientDataJSON:n(t.clientDataJSON),signature:n(t.signature),userHandle:t.userHandle?n(t.userHandle):null},clientExtensionResults:e.getClientExtensionResults?.()??{}}}async function o(){if("u"<typeof window)return!1;let{PublicKeyCredential:e}=window;if(!e)return!1;if("function"==typeof e.isConditionalMediationAvailable)try{if(await e.isConditionalMediationAvailable())return!0}catch{}if("function"==typeof e.isUserVerifyingPlatformAuthenticatorAvailable)try{return await e.isUserVerifyingPlatformAuthenticatorAvailable()}catch{return!1}return!0}s.d(t,{Il:()=>i,TA:()=>o,ig:()=>r})},67060(e,t,s){s.r(t),s.d(t,{component:()=>H});var a=s(72361),n=s(68413),r=s(45064),i=s(71114),o=s(6702),l=s(20598),c=s(61631),d=s(99170),u=s(30464),h=s(46775),f=s(16272),g=s(23507),m=s(74657),p=s(23780),x=s(1755),y=s(72982),w=s(17720),j=s(35491),b=s(88330);function v(e){let{open:t,onOpenChange:s,email:r,redirectTo:i}=e,o=(0,g.rM)(),{handleLoginSuccess:c,redirectTo2FA:d}=(0,w.u)(),{verify:u}
1=(0,j.E)(),[m,v]=(0,n.useState)(""),[C,_]=(0,n.useState)(!1),[N,k]=(0,n.useState)(!1),[S,R]=(0,n.useState)(60);async function I(e){if(6===e.length&&!C){_(!0);try{let t=await (0,f.HU)({email:r,verification_code:e});if(t.success){if(t.data?.require_2fa){s(!1),d();return}await c(t.data,i),(0,b.PI)(),l.oR.success(o.signIn.loginSuccess),s(!1)}else v("")}catch(e){v("")}finally{_(!1)}}}async function E(){if(S>0||N)return;let e=await u();if(null!==e){k(!0);try{let t=await (0,f.pX)(r,void 0,"disabled"===e?void 0:e);t.success?(l.oR.success(o.signIn.codeSent),R(60)):t.message&&l.oR.error(t.message)}catch(e){}finally{k(!1)}}}return(0,n.useEffect)(()=>{t&&(v(""),R(60))},[t]),(0,n.useEffect)(()=>{if(!t||S<=0)return;let e=setInterval(()=>R(e=>e-1),1e3);return()=>clearInterval(e)},[t,S]),(0,a.jsx)(x.lG,{open:t,onOpenChange:s,children:(0,a.jsxs)(x.Cf,{className:"max-w-sm",children:[(0,a.jsxs)(x.c7,{className:"text-left",children:[(0,a.jsx)(x.L3,{children:o.signIn.codeTitle}),(0,a.jsx)(x.rr,{className:"break-all",children:o.signIn.codeDescription.replace("{email}",r)})]}),(0,a.jsxs)("div",{className:"grid gap-4 pt-1",children:[(0,a.jsx)(y.UV,{maxLength:6,value:m,autoFocus:!0,onChange:e=>{v(e),6===e.length&&I(e)},containerClassName:"justify-center",disabled:C,children:(0,a.jsx)(y.NV,{children:Array.from({length:6},(e,t)=>(0,a.jsx)(y.sF,{index:t},t))})}),(0,a.jsx)(p.o,{type:"button",size:"lg",loading:C,disabled:6!==m.length||C,onClick:()=>void I(m),className:"w-full justify-center",children:o.signIn.verifyLabel}),(0,a.jsx)(h.$,{type:"button",variant:"ghost",size:"sm",className:"mx-auto h-8 px-2",disabled:S>0||N,onClick:E,children:S>0?o.signIn.resendCountdown.replace("{seconds}",String(S)):o.signIn.resendLabel})]})]})})}var C=s(91835),_=s(64096),N=s(72964),k=s(86832),S=s(48367),R=s(54369),I=s(81204),E=s(97077),A=s(54023),P=s(61309),F=s(10032),L=s(76614),z=s(13805),U=s(80211),B=s(88901),M=s(23973),V=s(89806),W=s(46499);function D(e){let{className:t,redirectTo:s,initialUsername:r="",hideUsernameField:d=!1,...g}=e,{t:m}
1=(0,o.Bd)(),[y,v]=(0,n.useState)(!1),[C,_]=(0,n.useState)(""),[N,D]=(0,n.useState)(!1),[H,T]=(0,n.useState)(!1),[$,q]=(0,n.useState)(!1),[J,O]=(0,n.useState)(!1),[G,Q]=(0,n.useState)(!1),K=m("Please agree to the legal terms first"),X=m("Login failed"),{status:Y}=(0,u.s)(),Z=!!(Y?.passkey_login??Y?.data?.passkey_login),ee=(Y?.password_login_enabled??Y?.data?.password_login_enabled??!0)!==!1,{isTurnstileEnabled:et,turnstileSiteKey:es,turnstileToken:ea,setTurnstileToken:en,validateTurnstile:er}=(0,M.A)(),{isTencentCaptchaEnabled:ei,verify:eo}=(0,j.E)(),{handleLoginSuccess:el,redirectTo2FA:ec}=(0,w.u)(),ed=!!Y?.user_agreement_enabled,eu=!!Y?.privacy_policy_enabled,eh=ed||eu,ef=$||!H||eh&&!N,eg=!!Y?.wechat_login,em=!!(Y?.github_oauth||Y?.discord_oauth||Y?.oidc_enabled||Y?.linuxdo_oauth||Y?.telegram_oauth||(Y?.custom_oauth_providers?.length??0)>0),ep=Z||eg||em;(0,n.useEffect)(()=>{(0,R.TA)().then(T).catch(()=>T(!1))},[]);let ex=(0,k.mN)({resolver:(0,S.u)(B.ni),defaultValues:{username:r,password:""}});(0,n.useEffect)(()=>{r&&ex.setValue("username",r)},[ex,r]);let ey=(0,n.useMemo)(()=>Y?.wechat_qrcode||Y?.wechat_qr_code||Y?.wechat_qrcode_image_url||Y?.wechat_qr_code_image_url||Y?.wechat_account_qrcode_image_url||Y?.WeChatAccountQRCodeImageURL||Y?.data?.wechat_qrcode||Y?.data?.WeChatAccountQRCodeImageURL||"",[Y]);async function ew(e){if(eh&&!N)return void l.oR.error(K);if(!ei&&!er())return;let t=await eo();if(null!==t){v(!0);try{let a=await (0,f.iD)({username:e.username,password:e.password,turnstile:ea},"disabled"===t?void 0:t);if(a.success){if(a.data?.require_2fa)return void ec();await el(a.data,s),(0,b.PI)(),l.oR.success(m("Welcome back!"))}}catch(e){}finally{v(!1)}}}let ej=e=>{O(e),e||(_(""),Q(!1))};async function eb(){if(!C.trim())return void l.oR.error(m("Please enter the verification code"));Q(!0);try{let e=await (0,f.Cw)(C);e?.success?(await el(e.data,s),l.oR.success(m("Signed in via WeChat")),ej(!1)):l.oR.error(e?.message||X)}catch(e){l.oR.error(X)}finally{Q(!1)}}async function ev(){if(eh&&!N)return void l.oR.error(K);if(!H)return void l.oR.error(m("Passkey is not supported on this device"));if(!navigator?.credentials)return void l.oR.error(m("Passkey is not available in this browser"));q(!0);try{let e=await (0,V.nc)();if(!e.success)throw Error(e.message||m("Failed to start Passkey login"));let t=(0,R.ig)(e.data?.options??e.data),a=await navigator.credentials.get({publicKey:t});if(!a)return void l.oR.info(m("Passkey login was cancelled"));let n=(0,R.Il)(a);if(!n)throw Error(m("Invalid Passkey response"));let r=await (0,V.$e)(n);if(!r.success)throw Error(r.message||m("Failed to complete Passkey login"));if(!r.data)throw Error(m("Missing user data from Passkey login response"));await el(r.data,s),l.oR.success(m("Signed in with Passkey"))}catch(e){e instanceof DOMException&&"NotAllowedError"===e.name?l.oR.info(m("Passkey login was cancelled or timed out")):e instanceof Error?l.oR.error(e.message):l.oR.error(m("Passkey login failed"))}finally{q(!1)}}let eC=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(U.m,{status:Y,disabled:y||eh&&!N,onWeChatLogin:eg?()=>{eh&&!N?l.oR.error(K):O(!0)}:void 0,isWeChatLoading:G}),Z&&(0,a.jsxs)(h.$,{type:"button",variant:"outline",size:"lg",disabled:ef,onClick:ev,className:"w-full justify-center gap-2",children:[$?(0,a.jsx)(c.krw,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(c.kVM,{className:"h-4 w-4"}),m("Sign in with Passkey")]})]});return(0,a.jsxs)(E.lV,{...ex,children:[(0,a.jsxs)("form",{onSubmit:ex.handleSubmit(ew),className:(0,I.cn)("grid gap-4",t),...g,children:[ee&&(0,a.jsxs)(a.Fragment,{children:[!d&&(0,a.jsx)(E.zB,{control:ex.control,name:"username",render:e=>{let{field:t}=e;return(0,a.jsxs)(E.eI,{children:[(0,a.jsx)(E.lR,{children:m("Username or Email")}),(0,a.jsx)(E.MJ,{children:(0,a.jsx)(W.C,{icon:(0,a.jsx)(c.KJW,{}),children:(0,a.jsx)(A.p,{placeholder:m("Enter your username or email"),autoComplete:"username",...t})})}),(0,a.jsx)(E.C5,{})]})}}),(0,a.jsx)(E.zB,{control:ex.control,name:"password",render:e=>{let{field:t}=e;return(0,a.jsxs)(E.eI,{className:"relative",children:[(0,a.jsx)(E.lR,{children:m("Password")}),(0,a.jsx)(E.MJ,{children:(0,a.jsx)(W.C,{icon:(0,a.jsx)(c.Uzy,{}),children:(0,a.jsx)(F.y,{placeholder:m("Enter password"),autoComplete:"current-password",autoFocus:d,...t})})}),(0,a.jsx)(E.C5,{}),(0,a.jsx)(i.N_,{to:"/forgot-password",className:"text-muted-foreground absolute end-0 -top-0.5 z-10 text-sm font-medium hover:opacity-75",onClick:()=>{let e=ex.getValues("username");e.includes("@")&&(0,b.zx)(e)},children:m("Forgot password?")})]})}}),(0,a.jsx)(z.G,{status:Y,checked:N,onCheckedChange:D}),(0,a.jsxs)(p.o,{type:"submit",size:"lg",loading:y,className:"mt-1 w-full justify-center gap-2",disabled:y||eh&&!N,children:[!y&&(0,a.jsx)(c.G5D,{}),m("Sign in")]}),et&&!ei&&(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)(L.X,{siteKey:es,onVerify:en})})]}),!ee&&(0,a.jsx)(z.G,{status:Y,checked:N,onCheckedChange:D,className:"mt-1"}),ep&&eC]}),eg&&(0,a.jsx)(x.lG,{open:J,onOpenChange:ej,children:(0,a.jsxs)(x.Cf,{className:"max-w-sm",children:[(0,a.jsxs)(x.c7,{className:"text-left",children:[(0,a.jsx)(x.L3,{children:m("WeChat sign in")}),(0,a.jsx)(x.rr,{children:m("Scan the QR code to follow the official account and reply with âéªè¯ç â to receive your verification code.")})]}),ey?(0,a.jsx)("div",{className:"flex justify-center",children:(0,a.jsx)("img",{src:ey,alt:m("WeChat login QR code"),className:"h-40 w-40 rounded-md border object-contain"})}):(0,a.jsx)("p",{className:"text-muted-foreground text-sm",children:m("QR code is not configured. Please contact support.")}),(0,a.jsxs)("div",{className:"grid gap-2",children:[(0,a.jsx)(P.J,{htmlFor:"wechat-code",children:m("Verification code")}),(0,a.jsx)(A.p,{id:"wechat-code",placeholder:m("Enter the verification code"),value:C,onChange:e=>_(e.target.value),autoComplete:"one-time-code"})]}),(0,a.jsxs)(x.Es,{children:[(0,a.jsx)(h.$,{type:"button",variant:"outline",onClick:()=>ej(!1),disabled:G,children:m("Cancel")}),(0,a.jsxs)(h.$,{type:"button",onClick:eb,disabled:G||!C.trim()||eh&&!N,className:"gap-2",children:[G?(0,a.jsx)(c.krw,{className:"h-4 w-4 animate-spin"}):null,m("Confirm")]})]})]})})]})}let H=function(){let{t:e}=(0,o.Bd)(),t=(0,g.rM)(),{redirect:s}=(0,r.S)({from:"/(auth)/sign-in"}),{status:p}
1=(0,u.s)(),[x,y]=(0,n.useState)(()=>(0,b.SW)()??""),[w,k]=(0,n.useState)("email"),[S,R]=(0,n.useState)(!1),{verify:I}=(0,j.E)();(0,d.H)(e("Sign in"));let E=(p?.password_login_enabled??p?.data?.password_login_enabled??!0)!==!1,A=!p?.self_use_mode_enabled&&p?.register_enabled!==!1,P=E?w:"legacy",F=async e=>{let s=(0,b.zx)(e);y(s);let a=await I();if(null===a)return;let n=await (0,f.pX)(s,void 0,"disabled"===a?void 0:a);if(n.success){l.oR.success(t.signIn.codeSent),R(!0);return}throw n.message&&l.oR.error(n.message),Error(n.message||"send code failed")},L=(0,a.jsx)(N.N,{variant:"sign-in",status:p,className:"text-center text-xs"}),z=(0,a.jsxs)(h.$,{type:"button",variant:"ghost",size:"sm",className:"h-8 gap-1.5 px-2",onClick:()=>k("legacy"),children:[(0,a.jsx)(c.kVM,{"aria-hidden":"true"}),t.signIn.classicLabel]}),U=A?(0,a.jsx)(i.N_,{to:"/sign-up",onClick:()=>(0,b.zx)(x),className:"text-foreground font-medium underline underline-offset-4 hover:no-underline",children:t.signIn.createAccountLabel}):null;return(0,a.jsxs)(m.D,{contentClassName:"mx-auto w-full max-w-[400px] space-y-6",children:["email"===P?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(C.L,{title:t.signIn.title,description:t.signIn.description,extraContent:(0,a.jsx)(_.X,{status:p}),initialEmail:x,submitLabel:t.signIn.continueLabel,onContinue:F,secondaryActions:(0,a.jsxs)(a.Fragment,{children:[z,U]})}),L]}):"password"===P?(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("h2",{className:"text-xl font-semibold tracking-tight",children:t.signIn.passwordTitle}),(0,a.jsx)("p",{className:"text-muted-foreground text-sm",children:t.signIn.passwordDescription})]}),(0,a.jsx)(C.l,{email:x,changeLabel:t.signIn.changeEmail,onChange:()=>k("email")}),(0,a.jsx)(D,{redirectTo:s,initialUsername:x,hideUsernameField:!0}),(0,a.jsxs)("div",{className:"border-border flex flex-wrap items-center justify-center gap-x-3 gap-y-2 border-t pt-5 text-sm",children:[z,U]})]}):(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("h2",{className:"text-xl font-semibold tracking-tight",children:e("Sign in")}),(0,a.jsx)("p",{className:"text-muted-foreground text-sm",children:e("Welcome back! Please enter your details.")})]}),(0,a.jsx)(D,{redirectTo:s}),E?(0,a.jsx)(h.$,{type:"button",variant:"ghost",size:"sm",className:"mx-auto flex h-8 px-2",onClick:()=>k("email"),children:t.signIn.backToModernLabel}):null,A?(0,a.jsxs)("p",{className:"text-muted-foreground pt-2 text-center text-sm",children:[e("Don't have an account?")," ",(0,a.jsx)(i.N_,{to:"/sign-up",className:"text-foreground font-medium underline underline-offset-4 hover:no-underline",children:e("Sign up")})]}):null]}),(0,a.jsx)(v,{open:S,onOpenChange:R,email:x,redirectTo:s})]})}}}]);
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.