1import{r as I,s as U,q as W,c as Y,e as J,_ as Z,f as X,g as ee,a as te}from"./SectionHeading.vue_vue_type_script_setup_true_lang-C5z5pXSb.js";import{_ as oe}from"./Modal.vue_vue_type_script_setup_true_lang-CsgFg5xx.js";import{b as A,_ as b}from"./index-DmVi5_c7.js";import{_ as se}from"./FormInput.vue_vue_type_script_setup_true_lang-DD9SnZBA.js";import{_ as ae}from"./FormError.vue_vue_type_script_setup_true_lang-CU6JEh93.js";import{e as K,a as g,d as z,w as ne,A as R,B as u,D as e,C as n,E as y,H as a,M as x,x as t,N as B,F as p,P as N,K as j,G as o,_ as le,o as re,L as ie,n as ce,b as ue,Y as de,Z as me}from"./vendor-vue-core-DTDbMvvN.js";import{f as q,h as fe}from"./vendor-inertia-DsG4W1gU.js";import{b as pe}from"./vendor-vueuse-Ck8ZVo2D.js";import"./AppLayout.vue_vue_type_script_setup_true_lang-BH8ReVZt.js";import"./vendor-i18n--PNt62Eh.js";import"./PreviewBanner.vue_vue_type_script_setup_true_lang-RSYhz2Fx.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./index-CoJ6Fwps.js";import"./index-DaT4Hqzw.js";import"./index-D84EFrKv.js";import"./app-Bokj3-Xn.js";const O=async m=>{const i=await fetch(m,{headers:{Accept:"application/json"}});if(!i.ok)throw new Error(`Failed to fetch: ${i.status}`);return i.json()},E=g([]),S=g(null),F=g(null),V=g([]),ve=K(()=>F.value!==null&&S.value!==null),L=()=>{const m=async()=>{try{const{svg:h}=await O(W.url());F.value=h}catch{E.value.push("Failed to fetch QR code"),F.value=null}},i=async()=>{try{const{secretKey:h}=await O(U.url());S.value=h}catch{E.value.push("Failed to fetch a setup key"),S.value=null}},d=()=>{S.value=null,F.value=null,r()},r=()=>{E.value=[]};return{qrCodeSvg:F,manualSetupKey:S,recoveryCodesList:V,errors:E,hasSetupData:ve,clearSetupData:d,clearErrors:r,clearTwoFactorAuthData:()=>{d(),r(),V.value=[]},fetchQrCode:m,fetchSetupKey:i,fetchSetupData:async()=>{try{r(),await Promise.all([m(),i()])}catch{F.value=null,S.value=null}},fetchRecoveryCodes:async()=>{try{r(),V.value=await O(I.url())}catch{E.value.push("Failed to fetch recovery codes"),V.value=[]}}}},ye={class:"flex flex-col p-xl"},he={class:"flex items-center gap-3 mb-md pr-8"},xe={class:"text-h5 font-medium text-dark-violet"},be={class:"mt-0.5 text-sm text-gray"},ge={class:"flex flex-1 flex-col"},we={key:0,class:"rounded-xl bg-pamplemousse/10 p-sm"},_e={class:"flex justify-center"},Ce={class:"relative aspect-square w-56 overflow-hidden rounded-xl border border-border bg-white"},ke={key:0,class:"flex size-full animate-pulse items-center justify-center bg-cream"},Se=["innerHTML"],Fe={class:"mt-md"},$e={class:"mt-md flex items-stretch overflow-hidden rounded-lg border border-border"},Te={key:0,class:"flex h-14 w-full items-center justify-center bg-cream"},Ee=["value"],Re=["value"],De={class:"flex flex-col gap-sm"},Ae={class:"flex items-center gap-3"},Ve=z({__name:"TwoFactorSetupModal",props:{requiresConfirmation:{type:Boolean},twoFactorEnabled:{type:Boolean},isOpen:{type:Boolean}},emits:["close"],setup(m,{emit:i}){const d=m,r=i,{copy:f,copied:s}=pe(),{qrCodeSvg:c,manualSetupKey:h,clearSetupData:w,fetchSetupData:v,errors:k}=L(),$=g(!1),_=g(""),P=K(()=>d.twoFactorEnabled?{title:"Two-Factor Authentication Enabled",description:"Two-factor authentication is now enabled. Scan the QR code or enter the setup key in your authenticator app."}:$.value?{title:"Verify Authentication Code",description:"Enter the 6-digit code from your authenticator app to confirm setup."}:{title:"Enable Two-Factor Authentication",description:"Scan the QR code or enter the setup key in your authenticator app to get started."}),Q=()=>{if(d.requiresConfirmation){$.value=!0;return}w(),r("close")},H=()=>{r("close")},G=()=>{d.twoFactorEnabled&&w(),$.value=!1,_.value=""};return ne(()=>d.isOpen,async M=>{if(!M){G();return}c.value||await v()}),(M,l)=>(o(),R(oe,{isOpen:m.isOpen,onClose:H},{default:u(()=>[e("div",ye,[e("div",he,[n(A,{name:"ScanQrCode",size:56,class:"text-orange"}),e("div",null,[e("h3",xe,y(P.value.title),1),e("p",be,y(P.value.description),1)])]),e("div",ge,[$.value?(o(),R(t(q),j({key:1},t(Y).form(),{resetOnError:"",onFinish:l[4]||(l[4]=C=>_.value=""),onSuccess:l[5]||(l[5]=C=>r("close"))}),{default:u(({errors:C,processing:T})=>[e("input",{type:"hidden",name:"code",value:_.value},null,8,Re),e("div",De,[n(se,{id:"two-factor-code",label:"Authentication code",type:"text",inputmode:"numeric",pattern:"[0-9]*",autocomplete:"one-time-code",placeholder:"000000",maxlength:"6",modelValue:_.value,"onUpdate:modelValue":l[1]||(l[1]=D=>_.value=D),onInput:l[2]||(l[2]=D=>_.value=D.target.value.replace(/\D/g,"").slice(0,6)),error:C?.code,"input-class":"font-mono text-center tracking-[0.5em] text-lg"},null,8,["modelValue","error"]),n(ae,{message:C?.code},null,8,["message"]),e("div",Ae,[n(b,{variant:"secondary",class:"flex-1",onClick:l[3]||(l[3]=D=>$.value=!1),disabled:T},{default:u(()=>[...l[8]||(l[8]=[p(" Back ",-1)])]),_:1},8,["disabled"]),n(b,{type:"submit",class:"flex-1",disabled:T||_.value.length<6},{default:u(()=>[p(y(T?"Confirming...":"Confirm"),1)]),_:2},1032,["disabled"])])])]),_:1},16)):(o(),a(x,{key:0},[t(k)?.length?(o(),a("div",we,[(o(!0),a(x,null,B(t(k),(C,T)=>(o(),a("p",{key:T,class:"text-sm text-pamplemousse"},y(C),1))),128))])):(o(),a(x,{key:1},[e("div",_e,[e("div",Ce,[t(c)?(o(),a("div",{key:1,innerHTML:t(c),class:"flex size-full items-center justify-center p-4"},null,8,Se)):(o(),a("div",ke,[n(A,{name:"LoaderCircle",size:24,class:"animate-spin text-gray"})]))])]),e("div",Fe,[n(b,{class:"w-full",onClick:Q},{default:u(()=>[...l[6]||(l[6]=[p(" Continue ",-1)])]),_:1})]),l[7]||(l[7]=e("div",{class:"relative mt-md flex items-center justify-center"},[e("div",{class:"absolute inset-0 top-1/2 h-px w-full bg-border"}),e("span",{class:"relative bg-white px-3 text-sm text-gray"},"or, enter the code manually")],-1)),e("div",$e,[t(h)?(o(),a(x,{key:1},[e("input",{type:"text",readonly:"",value:t(h),class:"w-full bg-cream h-14 px-6 font-mono text-sm text-gray focus:outline-none"},null,8,Ee),e("button",{onClick:l[0]||(l[0]=C=>t(f)(t(h)||"")),class:"flex shrink-0 items-center justify-center border-l border-border px-4 text-gray transition-colors duration-150 hover:bg-cream hover:text-dark-violet cursor-pointer"},[n(A,{name:t(s)?"Check":"Copy",size:16,class:N(t(s)?"text-green":"")},null,8,["name","class"])])],64)):(o(),a("div",Te,[n(A,{name:"LoaderCircle",size:20,class:"animate-spin text-gray"})]))])],64))],64))])])]),_:1},8,["isOpen"]))}}),Be={class:"w-full"},qe={class:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between"},Oe={key:0,class:"mt-sm rounded-xl bg-pamplemousse/10 p-sm"},ze={key:1,class:"mt-sm space-y-3"},je={key:0,class:"space-y-2"},Le=z({__name:"TwoFactorRecoveryCodes",setup(m){const{recoveryCodesList:i,fetchRecoveryCodes:d,errors:r}=L(),f=g(!1),s=le("recoveryCodeSectionRef"),c=async()=>{!f.value&&!i.value.length&&await d(),f.value=!f.value,f.value&&(
1await ce(),s.value?.scrollIntoView({behavior:"smooth"}))};return re(async()=>{i.value.length||await d()}),(h,w)=>(o(),a("div",Be,[e("div",qe,[n(b,{variant:"secondary",size:"sm",icon:f.value?"EyeOff":"Eye","icon-position":"left",onClick:c},{default:u(()=>[p(y(f.value?"Hide":"View")+" Recovery Codes ",1)]),_:1},8,["icon"]),f.value&&t(i).length?(o(),R(t(q),j({key:0},t(J).form(),{method:"post",options:{preserveScroll:!0},onSuccess:t(d)}),{default:u(({processing:v})=>[n(b,{variant:"ghost",size:"sm",icon:"RefreshCw","icon-position":"left",type:"submit",disabled:v},{default:u(()=>[...w[0]||(w[0]=[p(" Regenerate Codes ",-1)])]),_:1},8,["disabled"])]),_:1},16,["onSuccess"])):ie("",!0)]),e("div",{class:N(["relative overflow-hidden transition-all duration-300",f.value?"h-auto opacity-100":"h-0 opacity-0"])},[t(r)?.length?(o(),a("div",Oe,[(o(!0),a(x,null,B(t(r),(v,k)=>(o(),a("p",{key:k,class:"text-sm text-pamplemousse"},y(v),1))),128))])):(o(),a("div",ze,[e("div",{ref_key:"recoveryCodeSectionRef",ref:s,class:"grid gap-1 rounded-xl bg-cream p-sm font-mono text-sm text-dark-violet"},[t(i).length?(o(!0),a(x,{key:1},B(t(i),(v,k)=>(o(),a("div",{key:k},y(v),1))),128)):(o(),a("div",je,[(o(),a(x,null,B(8,v=>e("div",{key:v,class:"h-4 animate-pulse rounded bg-dark-violet/10"})),64))]))],512),w[1]||(w[1]=e("p",{class:"text-sm text-gray select-none"},[p(" Each recovery code can be used once to access your account and will be removed after use. Click "),e("span",{class:"font-bold"},"Regenerate Codes"),p(" above if you need more. ")],-1))]))],2)]))}}),Pe={class:"rounded-lg bg-white p-xl"},Me={key:0,class:"flex flex-col items-start gap-md"},Ke={key:1,class:"flex flex-col items-start gap-md"},nt=z({__name:"TwoFactor",props:{requiresConfirmation:{type:Boolean,default:!1},twoFactorEnabled:{type:Boolean,default:!1}},setup(m){const{hasSetupData:i,clearTwoFactorAuthData:d}=L(),r=g(!1);return ue(()=>{d()}),(f,s)=>(o(),a(x,null,[n(t(fe),{title:"Your account - Two-factor authentication"}),n(te,null,{default:u(()=>[e("div",Pe,[n(Z,{icon:"ShieldCheck",title:"Two-factor authentication",subtitle:"Add additional security to your account using two-factor authentication."}),m.twoFactorEnabled?(o(),a("div",Ke,[s[6]||(s[6]=e("div",{class:"w-full md:w-auto rounded-xl bg-green/10 px-4 py-3"},[e("p",{class:"text-sm font-medium text-green"}," Two-factor authentication is enabled. ")],-1)),s[7]||(s[7]=e("p",{class:"text-md text-gray"}," With two-factor authentication enabled, you will be prompted for a secure, random code during login, which you can retrieve from the TOTP-supported application on your phone. ",-1)),n(Le),n(t(q),de(me(t(ee).form())),{default:u(({processing:c})=>[n(b,{variant:"ghost",type:"submit",icon:"ShieldBan","icon-position":"left",disabled:c,class:"text-pamplemousse hover:text-pamplemousse/80"},{default:u(()=>[p(y(c?"Disabling...":"Disable 2FA"),1)]),_:2},1032,["disabled"])]),_:1},16)])):(o(),a("div",Me,[s[4]||(s[4]=e("div",{class:"w-full md:w-auto rounded-xl bg-orange/10 px-4 py-3"},[e("p",{class:"text-sm font-medium text-dark-violet"}," Two-factor authentication is not enabled. ")],-1)),s[5]||(s[5]=e("p",{class:"text-md text-gray"}," When you enable two-factor authentication, you will be prompted for a secure code during login. This code can be retrieved from a TOTP-supported application on your phone, such as Google Authenticator or 1Password. ",-1)),e("div",null,[t(i)?(o(),R(b,{key:0,icon:"ShieldCheck","icon-position":"left",onClick:s[0]||(s[0]=c=>r.value=!0)},{default:u(()=>[...s[3]||(s[3]=[p(" Continue Setup ",-1)])]),_:1})):(o(),R(t(q),j({key:1},t(X).form(),{onSuccess:s[1]||(s[1]=c=>r.value=!0)}),{default:u(({processing:c})=>[n(b,{type:"submit",icon:"ShieldCheck","icon-position":"left",disabled:c},{default:u(()=>[p(y(c?"Enabling...":"Enable 2FA"),1)]),_:2},1032,["disabled"])]),_:1},16))])])),n(Ve,{isOpen:r.value,requiresConfirmation:m.requiresConfirmation,twoFactorEnabled:m.twoFactorEnabled,onClose:s[2]||(s[2]=c=>r.value=!1)},null,8,["isOpen","requiresConfirmation","twoFactorEnabled"])])]),_:1})],64))}});export{nt 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.