Files
soorya-carpet/public/build/assets/two-factor-BgvsQlzz.js
admin 9c703306ec
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
chore: build
2025-10-27 21:32:05 +05:45

47 lines
16 KiB
JavaScript

import{j as e,r as i,F as y,H as T}from"./app-Ajql0Lt4.js";import{S as _,H as A}from"./layout-B-QAbSfv.js";import{a as x,c as h,m as k,B as f,S as M}from"./createLucideIcon-B_iAwCmA.js";import{c as F,d as V,b as z,e as R,f as E}from"./index-D6lErTwd.js";import{I}from"./input-error-Drp3HhtP.js";import{D as O,b as H,g as $,c as D,d as L}from"./dialog-CTDbVFLX.js";import{I as B,K as P,O as v,a as q,b as G,u as K}from"./use-two-factor-auth-PVYcuVkA.js";import{L as j}from"./loader-circle-C6-iW413.js";import{C as Q}from"./check-D1N7nvmG.js";import{A as W}from"./app-layout-BTSySP9M.js";import"./app-B4XVefei.js";import"./index-em-EQZzp.js";import"./index-BPJbFReo.js";import"./index-B6hfytYC.js";import"./sheet-iBbRuLZ4.js";import"./index-CS1SDu2T.js";import"./index-UHLdfeKp.js";import"./app-logo-icon-B9D8MR-Y.js";import"./package-CgKP903x.js";/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const X=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],J=x("CircleAlert",X);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const U=[["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"}]],Y=x("Copy",U);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Z=[["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"}]],ee=x("EyeOff",Z);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const te=[["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"}]],re=x("Eye",te);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ae=[["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"}]],se=x("LockKeyhole",ae);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ne=[["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"}]],ie=x("RefreshCw",ne);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const oe=[["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"}]],ce=x("ScanLine",oe);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const le=[["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"}]],de=x("ShieldBan",le);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ue=[["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:"m9 12 2 2 4-4",key:"dzmm74"}]],w=x("ShieldCheck",ue);function xe({className:r,...t}){return e.jsx("div",{"data-slot":"card",className:h("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",r),...t})}function he({className:r,...t}){return e.jsx("div",{"data-slot":"card-header",className:h("flex flex-col gap-1.5 px-6",r),...t})}function me({className:r,...t}){return e.jsx("div",{"data-slot":"card-title",className:h("leading-none font-semibold",r),...t})}function fe({className:r,...t}){return e.jsx("div",{"data-slot":"card-description",className:h("text-muted-foreground text-sm",r),...t})}function pe({className:r,...t}){return e.jsx("div",{"data-slot":"card-content",className:h("px-6",r),...t})}const ge=k("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-background text-foreground",destructive:"text-destructive-foreground [&>svg]:text-current *:data-[slot=alert-description]:text-destructive-foreground/80"}},defaultVariants:{variant:"default"}});function ye({className:r,variant:t,...s}){return e.jsx("div",{"data-slot":"alert",role:"alert",className:h(ge({variant:t}),r),...s})}function ve({className:r,...t}){return e.jsx("div",{"data-slot":"alert-title",className:h("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",r),...t})}function be({className:r,...t}){return e.jsx("div",{"data-slot":"alert-description",className:h("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",r),...t})}function C({errors:r,title:t}){return e.jsxs(ye,{variant:"destructive",children:[e.jsx(J,{}),e.jsx(ve,{children:t||"Something went wrong."}),e.jsx(be,{children:e.jsx("ul",{className:"list-inside list-disc text-sm",children:Array.from(new Set(r)).map((s,a)=>e.jsx("li",{children:s},a))})})]})}function je({recoveryCodesList:r,fetchRecoveryCodes:t,errors:s}){const[a,n]=i.useState(!1),o=i.useRef(null),c=r.length>0&&a,d=i.useCallback(async()=>{!a&&!r.length&&await t(),n(!a),a||setTimeout(()=>{o.current?.scrollIntoView({behavior:"smooth",block:"nearest"})})},[a,r.length,t]);i.useEffect(()=>{r.length||t()},[r.length,t]);const m=a?ee:re;return e.jsxs(xe,{children:[e.jsxs(he,{children:[e.jsxs(me,{className:"flex gap-3",children:[e.jsx(se,{className:"size-4","aria-hidden":"true"}),"2FA Recovery Codes"]}),e.jsx(fe,{children:"Recovery codes let you regain access if you lose your 2FA device. Store them in a secure password manager."})]}),e.jsxs(pe,{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:d,className:"w-fit","aria-expanded":a,"aria-controls":"recovery-codes-section",children:[e.jsx(m,{className:"size-4","aria-hidden":"true"}),a?"Hide":"View"," Recovery Codes"]}),c&&e.jsx(y,{...F.form(),options:{preserveScroll:!0},onSuccess:t,children:({processing:l})=>e.jsxs(f,{variant:"secondary",type:"submit",disabled:l,"aria-describedby":"regenerate-warning",children:[e.jsx(ie,{})," Regenerate Codes"]})})]}),e.jsx("div",{id:"recovery-codes-section",className:`relative overflow-hidden transition-all duration-300 ${a?"h-auto opacity-100":"h-0 opacity-0"}`,"aria-hidden":!a,children:e.jsx("div",{className:"mt-3 space-y-3",children:s?.length?e.jsx(C,{errors:s}):e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:o,className:"grid gap-1 rounded-lg bg-muted p-4 font-mono text-sm",role:"list","aria-label":"Recovery codes",children:r.length?r.map((l,u)=>e.jsx("div",{role:"listitem",className:"select-text",children:l},u)):e.jsx("div",{className:"space-y-2","aria-label":"Loading recovery codes",children:Array.from({length:8},(l,u)=>e.jsx("div",{className:"h-4 animate-pulse rounded bg-muted-foreground/20","aria-hidden":"true"},u))})}),e.jsx("div",{className:"text-xs text-muted-foreground select-none",children:e.jsxs("p",{id:"regenerate-warning",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 we(){const[r,t]=i.useState(null),s=i.useCallback(async a=>{if(!navigator?.clipboard)return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(a),t(a),!0}catch(n){return console.warn("Copy failed",n),t(null),!1}},[]);return[r,s]}function Ne(){return e.jsx("div",{className:"mb-3 rounded-full border border-border bg-card p-0.5 shadow-sm",children:e.jsxs("div",{className:"relative overflow-hidden rounded-full border border-border bg-muted p-2.5",children:[e.jsx("div",{className:"absolute inset-0 grid grid-cols-5 opacity-50",children:Array.from({length:5},(r,t)=>e.jsx("div",{className:"border-r border-border last:border-r-0"},`col-${t+1}`))}),e.jsx("div",{className:"absolute inset-0 grid grid-rows-5 opacity-50",children:Array.from({length:5},(r,t)=>e.jsx("div",{className:"border-b border-border last:border-b-0"},`row-${t+1}`))}),e.jsx(ce,{className:"relative z-20 size-6 text-foreground"})]})})}function ke({qrCodeSvg:r,manualSetupKey:t,buttonText:s,onNextStep:a,errors:n}){const[o,c]=we(),d=o===t?Q:Y;return e.jsx(e.Fragment,{children:n?.length?e.jsx(C,{errors:n}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mx-auto flex max-w-md overflow-hidden",children:e.jsx("div",{className:"mx-auto aspect-square w-64 rounded-lg border border-border",children:e.jsx("div",{className:"z-10 flex h-full w-full items-center justify-center p-5",children:r?e.jsx("div",{dangerouslySetInnerHTML:{__html:r}}):e.jsx(j,{className:"flex size-4 animate-spin"})})})}),e.jsx("div",{className:"flex w-full space-x-5",children:e.jsx(f,{className:"w-full",onClick:a,children:s})}),e.jsxs("div",{className:"relative flex w-full items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 top-1/2 h-px w-full bg-border"}),e.jsx("span",{className:"relative bg-card px-2 py-1",children:"or, enter the code manually"})]}),e.jsx("div",{className:"flex w-full space-x-2",children:e.jsx("div",{className:"flex w-full items-stretch overflow-hidden rounded-xl border border-border",children:t?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",readOnly:!0,value:t,className:"h-full w-full bg-background p-3 text-foreground outline-none"}),e.jsx("button",{onClick:()=>c(t),className:"border-l border-border px-3 hover:bg-muted",children:e.jsx(d,{className:"w-4"})})]}):e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-muted p-3",children:e.jsx(j,{className:"size-4 animate-spin"})})})})]})})}function Ce({onClose:r,onBack:t}){const[s,a]=i.useState(""),n=i.useRef(null);return i.useEffect(()=>{setTimeout(()=>{n.current?.querySelector("input")?.focus()},0)},[]),e.jsx(y,{...V.form(),onSuccess:()=>r(),resetOnError:!0,resetOnSuccess:!0,children:({processing:o,errors:c})=>e.jsx(e.Fragment,{children:e.jsxs("div",{ref:n,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(B,{id:"otp",name:"code",maxLength:v,onChange:a,disabled:o,pattern:P,children:e.jsx(q,{children:Array.from({length:v},(d,m)=>e.jsx(G,{index:m},m))})}),e.jsx(I,{message:c?.confirmTwoFactorAuthentication?.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:o,children:"Back"}),e.jsx(f,{type:"submit",className:"flex-1",disabled:o||s.length<v,children:"Confirm"})]})]})})})}function Se({isOpen:r,onClose:t,requiresConfirmation:s,twoFactorEnabled:a,qrCodeSvg:n,manualSetupKey:o,clearSetupData:c,fetchSetupData:d,errors:m}){const[l,u]=i.useState(!1),p=i.useMemo(()=>a?{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"}:l?{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"},[a,l]),g=i.useCallback(()=>{if(s){u(!0);return}c(),t()},[s,c,t]),b=i.useCallback(()=>{u(!1),a&&c()},[a,c]);return i.useEffect(()=>{if(!r){b();return}n||d()},[r,n,d,b]),e.jsx(O,{open:r,onOpenChange:S=>!S&&t(),children:e.jsxs(H,{className:"sm:max-w-md",children:[e.jsxs($,{className:"flex items-center justify-center",children:[e.jsx(Ne,{}),e.jsx(D,{children:p.title}),e.jsx(L,{className:"text-center",children:p.description})]}),e.jsx("div",{className:"flex flex-col items-center space-y-5",children:l?e.jsx(Ce,{onClose:t,onBack:()=>u(!1)}):e.jsx(ke,{qrCodeSvg:n,manualSetupKey:o,buttonText:p.buttonText,onNextStep:g,errors:m})})]})})}const Te=k("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function N({className:r,variant:t,asChild:s=!1,...a}){const n=s?M:"span";return e.jsx(n,{"data-slot":"badge",className:h(Te({variant:t}),r),...a})}const _e=[{title:"Two-Factor Authentication",href:z.url()}];function We({requiresConfirmation:r=!1,twoFactorEnabled:t=!1}){const{qrCodeSvg:s,hasSetupData:a,manualSetupKey:n,clearSetupData:o,fetchSetupData:c,recoveryCodesList:d,fetchRecoveryCodes:m,errors:l}=K(),[u,p]=i.useState(!1);return e.jsxs(W,{breadcrumbs:_e,children:[e.jsx(T,{title:"Two-Factor Authentication"}),e.jsx(_,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(A,{title:"Two-Factor Authentication",description:"Manage your two-factor authentication settings"}),t?e.jsxs("div",{className:"flex flex-col items-start justify-start space-y-4",children:[e.jsx(N,{variant:"default",children:"Enabled"}),e.jsx("p",{className:"text-muted-foreground",children:"With two-factor authentication enabled, you will be prompted for a secure, random pin during login, which you can retrieve from the TOTP-supported application on your phone."}),e.jsx(je,{recoveryCodesList:d,fetchRecoveryCodes:m,errors:l}),e.jsx("div",{className:"relative inline",children:e.jsx(y,{...R.form(),children:({processing:g})=>e.jsxs(f,{variant:"destructive",type:"submit",disabled:g,children:[e.jsx(de,{})," Disable 2FA"]})})})]}):e.jsxs("div",{className:"flex flex-col items-start justify-start space-y-4",children:[e.jsx(N,{variant:"destructive",children:"Disabled"}),e.jsx("p",{className:"text-muted-foreground",children:"When you enable two-factor authentication, you will be prompted for a secure pin during login. This pin can be retrieved from a TOTP-supported application on your phone."}),e.jsx("div",{children:a?e.jsxs(f,{onClick:()=>p(!0),children:[e.jsx(w,{}),"Continue Setup"]}):e.jsx(y,{...E.form(),onSuccess:()=>p(!0),children:({processing:g})=>e.jsxs(f,{type:"submit",disabled:g,children:[e.jsx(w,{}),"Enable 2FA"]})})})]}),e.jsx(Se,{isOpen:u,onClose:()=>p(!1),requiresConfirmation:r,twoFactorEnabled:t,qrCodeSvg:s,manualSetupKey:n,clearSetupData:o,fetchSetupData:c,errors:l})]})})]})}export{We as default};