1import{r as o,j as e,S as v,m as R,L as A}from"./app-BzqCBKFq.js";import{c as j,B as f}from"./createLucideIcon-9pX33GdP.js";import{C as w,b as S,c as C,d as T,a as M,e as I}from"./card-Dz1taVRg.js";import{I as V,K as z,O as g,a as D,b as E,u as O}from"./use-two-factor-auth-CvaWwRRa.js";import{e as B,I as $}from"./input-error-iMATgqPn.js";import{D as H,b as F,c as P,d as q,e as G}from"./dialog-9Z3PUl1n.js";import{C as Q}from"./check-C_Rlw813.js";import{B as U}from"./badge-xdxMYL-I.js";import{L as W}from"./layout-GEvt5yYo.js";import{S as X}from"./layout-CN0jTq2X.js";import{L as N}from"./loader-circle-CSlPCcq7.js";/* empty css */import"./_commonjsHelpers-D6-XlEtG.js";import"./index-C-GmmI6E.js";import"./index-XYF8yV9E.js";import"./index-BKQG6xDZ.js";import"./index-CKsl_sWp.js";import"./index-C3ZIikIG.js";import"./x-D-3CxGCA.js";import"./tooltip-DLOhzh6m.js";import"./floating-ui.react-dom-BVAhhuy2.js";import"./dropdown-menu-Cn1ksCm3.js";import"./index-C-mHl93N.js";import"./index-Cv70i3ND.js";import"./toast-BK2vKZug.js";import"./heading-jwOZWGaR.js";/** 2 * @license lucide-react v0.483.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Y=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],J=j("Copy",Y);/** 7 * @license lucide-react v0.483.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const K=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Z=j("EyeOff",K);/** 12 * @license lucide-react v0.483.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const ee=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],te=j("Eye",ee);/** 17 * @license lucide-react v0.483.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const se=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],ae=j("LockKeyhole",se);/** 22 * @license lucide-react v0.483.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const re=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],oe=j("RefreshCw",re);/** 27 * @license lucide-react v0.483.0 - ISC 28 * 29 * This source code is licensed under the ISC license. 30 * See the LICENSE file in the root directory of this source tree. 31 */const ne=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 12h10",key:"b7w52i"}]],ie=j("ScanLine",ne);/** 32 * @license lucide-react v0.483.0 - ISC 33 * 34 * This source code is licensed under the ISC license. 35 * See the LICENSE file in the root directory of this source tree. 36 */const ce=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m4.243 5.21 14.39 12.472",key:"1c9a7c"}]],le=j("ShieldBan",ce);/** 37 * @license lucide-react v0.483.0 - ISC 38 * 39 * This source code is licensed under the ISC license. 40 * See the LICENSE file in the root directory of this source tree. 41 */const de=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",ke
41y:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],k=j("ShieldCheck",de);function ue({recoveryCodesList:a,fetchRecoveryCodes:t,errors:n}){const[s,c]=o.useState(!1),[l,i]=o.useState(!1),u=o.useRef(null),m=a.length>0&&s,r=o.useCallback(async()=>{!s&&!a.length&&await t(),c(!s),s||setTimeout(()=>{var h;(h=u.current)==null||h.scrollIntoView({behavior:"smooth",block:"nearest"})})},[s,a.length,t]);o.useEffect(()=>{a.length||t()},[a.length,t]);const d=()=>{i(!0),v.post("/user/two-factor-recovery-codes",{},{preserveScroll:!0,onSuccess:()=>{t(),i(!1)},onError:()=>i(!1)})},x=s?Z:te;return e.jsxs(w,{children:[e.jsxs(S,{children:[e.jsxs(C,{className:"flex gap-3",children:[e.jsx(ae,{className:"size-4","aria-hidden":"true"}),"2FA recovery codes"]}),e.jsx(T,{children:"Recovery codes let you regain access if you lose your 2FA device. Store them in a secure password manager."})]}),e.jsxs(M,{className:"p-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 select-none sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs(f,{onClick:r,className:"w-fit","aria-expanded":s,"aria-controls":"recovery-codes-section",children:[e.jsx(x,{className:"size-4","aria-hidden":"true"}),s?"Hide":"View"," recovery codes"]}),m&&e.jsxs(f,{variant:"secondary",onClick:d,disabled:l,children:[e.jsx(oe,{})," Regenerate codes"]})]}),e.jsx("div",{id:"recovery-codes-section",className:`relative overflow-hidden transition-all duration-300 ${s?"h-auto opacity-100":"h-0 opacity-0"}`,"aria-hidden":!s,children:e.jsx("div",{className:"mt-3 space-y-3",children:n!=null&&n.length?e.jsx("div",{className:"text-destructive rounded-lg border border-red-200 bg-red-50 p-4 text-sm dark:border-red-800 dark:bg-red-950",children:e.jsx("ul",{className:"list-inside list-disc",children:n.map((h,p)=>e.jsx("li",{children:h},p))})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:u,className:"bg-muted grid gap-1 rounded-lg p-4 font-mono text-sm",role:"list","aria-label":"Recovery codes",children:a.length?a.map((h,p)=>e.jsx("div",{role:"listitem",className:"select-text",children:h},p)):e.jsx("div",{className:"space-y-2","aria-label":"Loading recovery codes",children:Array.from({length:8},(h,p)=>e.jsx("div",{className:"bg-muted-foreground/20 h-4 animate-pulse rounded","aria-hidden":"true"},p))})}),e.jsx("div",{className:"text-muted-foreground text-xs select-none",children:e.jsxs("p",{children:["Each recovery code can be used once to access your account and will be removed after use. If you need more, click"," ",e.jsx("span",{className:"font-bold",children:"Regenerate codes"})," above."]})})]})})})]})]})}function he(){const[a,t]=o.useState(null),n=o.useCallback(async s=>{if(!(navigator!=null&&navigator.clipboard))return!1;try{return await navigator.clipboard.writeText(s),t(s),!0}catch{return t(null),!1}},[]);return[a,n]}function pe(){return e.jsx("div",{className:"border-border bg-card mb-3 rounded-full border p-0.5 shadow-sm",children:e.jsx("div",{className:"border-border bg-muted relative overflow-hidden rounded-full border p-2.5",children:e.jsx(ie,{className:"text-foreground relative z-20 size-6"})})})}function me({qrCodeSvg:a,manualSetupKey:t,buttonText:n,onNextStep:s,errors:c}){const[l,i]=he(),u=l===t?Q:J;return c!=null&&c.length?e.jsx("div",{role:"alert",className:"text-destructive w-full rounded-lg border border-red-200 bg-red-50 p-4 text-sm dark:border-red-800 dark:bg-red-950",children:e.jsx("ul",{className:"list-inside list-disc",children:c.map((m,r)=>e.jsx("li",{children:m},r))})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mx-auto flex max-w-md overflow-hidden",children:e.jsx("div",{className:"border-border mx-auto aspect-square w-64 rounded-lg border",children:e.jsx("div",{className:"z-10 flex h-full w-full items-center justify-center p-5",children:a?e.jsx("div",{"aria-hidden":"true",className:"aspect-square w-full rounded-lg bg-white p-2 dark:brightness-150 dark:invert [&_svg]:size-full",dangerouslySetInnerHTML:{__html:a}}):e.jsx("div",{className:"text-muted-foreground text-sm",children:"Loading..."})})})}),e.jsx("div",{className:"flex w-full space-x-5",children:e.jsx(f,{className:"w-full",onClick:s,children:n})}),e.jsxs("div",{className:"relative flex w-full items-center justify-center",children:[e.jsx("div",{className:"bg-border absolute inset-0 top-1/2 h-px w-full"}),e.jsx("span",{className:"bg-card relative px-2 py-1 text-sm",children:"or, enter the code manually"})]}),e.jsx("div",{className:"flex w-full space-x-2",children:e.jsx("div",{className:"border-border flex w-full items-stretch overflow-hidden rounded-xl border",children:t?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",readOnly:!0,"aria-label":"Setup key",value:t,className:"bg-background text-foreground h-full w-full p-3 outline-none"}),e.jsx("button",{type:"button",onClick:()=>i(t),"aria-label":l===t?"Setup key copied":"Copy setup key",className:"border-border hover:bg-muted border-l px-3",children:e.jsx(u,{"aria-hidden":"true",className:"w-4"})}),e.jsx("span",{role:"status",className:"sr-only",children:l===t?"
41Setup key copied to clipboard":""})]}):e.jsx("div",{className:"bg-muted flex h-full w-full items-center justify-center p-3",children:e.jsx("span",{className:"text-muted-foreground text-sm",children:"Loading..."})})})})]})}function xe({onClose:a,onBack:t}){const{data:n,setData:s,post:c,processing:l,errors:i}=R({code:""}),u=o.useRef(null);o.useEffect(()=>{setTimeout(()=>{var r,d;(d=(r=u.current)==null?void 0:r.querySelector("input"))==null||d.focus()},0)},[]);const m=r=>{r.preventDefault(),c("/user/confirmed-two-factor-authentication",{preserveScroll:!0,onSuccess:()=>a()})};return e.jsx("form",{onSubmit:m,children:e.jsxs("div",{ref:u,className:"relative w-full space-y-3",children:[e.jsxs("div",{className:"flex w-full flex-col items-center space-y-3 py-2",children:[e.jsx(V,{name:"code","aria-label":"Authentication code",maxLength:g,value:n.code,onChange:r=>s("code",r),disabled:l,pattern:z,...B("code",i.code),children:e.jsx(D,{children:Array.from({length:g},(r,d)=>e.jsx(E,{index:d},d))})}),e.jsx($,{field:"code",message:i.code})]}),e.jsxs("div",{className:"flex w-full space-x-5",children:[e.jsx(f,{type:"button",variant:"outline",className:"flex-1",onClick:t,disabled:l,children:"Back"}),e.jsx(f,{type:"submit",className:"flex-1",disabled:l||n.code.length<g,children:"Confirm"})]})]})})}function fe({isOpen:a,onClose:t,requiresConfirmation:n,twoFactorEnabled:s,qrCodeSvg:c,manualSetupKey:l,clearSetupData:i,fetchSetupData:u,errors:m}){const[r,d]=o.useState(!1),x=o.useMemo(()=>s?{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.",buttonText:"Close"}:r?{title:"Verify authentication code",description:"Enter the 6-digit code from your authenticator app",buttonText:"Continue"}:{title:"Enable two-factor authentication",description:"To finish enabling two-factor authentication, scan the QR code or enter the setup key in your authenticator app",buttonText:"Continue"},[s,r]),h=o.useCallback(()=>{if(n){d(!0);return}i(),t()},[n,i,t]),p=o.useCallback(()=>{d(!1),s&&i()},[s,i]);o.useEffect(()=>{a&&!c&&u()},[a,c,u]);const b=o.useCallback(()=>{p(),t()},[t,p]);return e.jsx(H,{open:a,onOpenChange:y=>!y&&b(),children:e.jsxs(F,{className:"sm:max-w-md",children:[e.jsxs(P,{className:"flex items-center justify-center",children:[e.jsx(pe,{}),e.jsx(q,{children:x.title}),e.jsx(G,{className:"text-center",children:x.description})]}),e.jsx("div",{className:"flex flex-col items-center space-y-5 p-4",children:r?e.jsx(xe,{onClose:t,onBack:()=>d(!1)}):e.jsx(me,{qrCodeSvg:c,manualSetupKey:l,buttonText:x.buttonText,onNextStep:h,errors:m})})]})})}function Pe({requiresConfirmation:a=!1,twoFactorEnabled:t=!1}){const{qrCodeSvg:n,hasSetupData:s,manualSetupKey:c,clearSetupData:l,fetchSetupData:i,recoveryCodesList:u,fetchRecoveryCodes:m,errors:r}
41=O(),[d,x]=o.useState(!1),[h,p]=o.useState(!1),[b,y]=o.useState(!1),_=()=>{p(!0),v.post("/user/two-factor-authentication",{},{preserveScroll:!0,onSuccess:()=>{x(!0),p(!1)},onError:()=>p(!1)})},L=()=>{y(!0),v.delete("/user/two-factor-authentication",{preserveScroll:!0,onSuccess:()=>y(!1),onError:()=>y(!1)})};return e.jsxs(W,{children:[e.jsx(A,{title:"Two-factor authentication"}),e.jsxs(X,{children:[e.jsxs(w,{children:[e.jsx(S,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{children:"Authentication app"}),e.jsx(T,{children:"Use an authenticator app to generate one-time codes for added security during login."})]}),e.jsx(U,{variant:t?"success":"destructive",children:t?"Enabled":"Disabled"})]})}),e.jsx(M,{className:"space-y-4 p-4",children:t?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Two-factor authentication is active. You will be prompted for a secure code from your authenticator app during login."}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"When enabled, you will be prompted for a secure code during login. This code can be retrieved from a TOTP-supported authenticator app on your phone, such as Google Authenticator or Authy."})}),e.jsx(I,{children:t?e.jsxs(f,{variant:"destructive",onClick:L,disabled:b,children:[b&&e.jsx(N,{className:"animate-spin"}),e.jsx(le,{}),"Disable 2FA"]}):s?e.jsxs(f,{onClick:()=>x(!0),children:[e.jsx(k,{}),"Continue setup"]}):e.jsxs(f,{onClick:_,disabled:h,children:[h&&e.jsx(N,{className:"animate-spin"}),e.jsx(k,{}),"Enable 2FA"]})})]}),t&&e.jsx(ue,{recoveryCodesList:u,fetchRecoveryCodes:m,errors:r}),e.jsx(fe,{isOpen:d,onClose:()=>x(!1),requiresConfirmation:a,twoFactorEnabled:t,qrCodeSvg:n,manualSetupKey:c,clearSetupData:l,fetchSetupData:i,errors:r})]})]})}export{Pe 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.