import{j as v,b9 as c,bq as u,B as i,D as t,S as w,ah as x,c0 as g,o as S,aK as I,ab as _,ag as $,aE as k,I as C,K as D,ao as T,a6 as d,r as q,bt as F,bb as K,d9 as L}from"./index-CNZMR1GT.js";const R=()=>{const{back:n}=v(),[l,p]=c(()=>u.post("/auth/2fa/generate")),a=S(),[r,h]=i(),f=async()=>{if(d().otp){q.warning(a("users.2fa_already_enabled")),n();return}const e=await p();F(e,h)},[s,y]=i("");f();const[b,m]=c(()=>{var e;return u.post("/auth/2fa/verify",{code:s(),secret:(e=r())==null?void 0:e.secret})}),o=async()=>{const e=await m();K(e,()=>{L({...d(),otp:!0}),n()})};return t(T,{get loading(){return l()},get children(){return t(w,{get when(){return r()},get children(){return t(x,{spacing:"$2",alignItems:"start",get children(){return[t(g,{get children(){return a("users.scan_qr")}}),t(I,{boxSize:"$xs",rounded:"$lg",get src(){var e;return(e=r())==null?void 0:e.qr}}),t(g,{get children(){return[_(()=>a("users.or_manual")),":"," ",t($,{get color(){return k()},get children(){var e;return(e=r())==null?void 0:e.secret}})]}}),t(C,{maxW:"$xs",get placeholder(){return a("users.input_code")},get value(){return s()},onInput:e=>y(e.currentTarget.value),onKeyDown:e=>{e.key==="Enter"&&o()}}),t(D,{get loading(){return b()},onClick:o,get children(){return a("users.verify")}})]}})}})}})};export{R as default};
