Files
soorya-carpet/public/build/assets/use-two-factor-auth-PVYcuVkA.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

26 lines
12 KiB
JavaScript

import{r as e,j as W}from"./app-Ajql0Lt4.js";import{a as je,c as J}from"./createLucideIcon-B_iAwCmA.js";import{q as Oe,a as De,r as Ie}from"./index-D6lErTwd.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 Ae=[["path",{d:"M5 12h14",key:"1ays0h"}]],Fe=je("Minus",Ae);var Ne=Object.defineProperty,We=Object.defineProperties,_e=Object.getOwnPropertyDescriptors,X=Object.getOwnPropertySymbols,ve=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable,he=(n,t,a)=>t in n?Ne(n,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[t]=a,Be=(n,t)=>{for(var a in t||(t={}))ve.call(t,a)&&he(n,a,t[a]);if(X)for(var a of X(t))ge.call(t,a)&&he(n,a,t[a]);return n},Le=(n,t)=>We(n,_e(t)),He=(n,t)=>{var a={};for(var o in n)ve.call(n,o)&&t.indexOf(o)<0&&(a[o]=n[o]);if(n!=null&&X)for(var o of X(n))t.indexOf(o)<0&&ge.call(n,o)&&(a[o]=n[o]);return a};function Ge(n){let t=setTimeout(n,0),a=setTimeout(n,10),o=setTimeout(n,50);return[t,a,o]}function $e(n){let t=e.useRef();return e.useEffect(()=>{t.current=n}),t.current}var Ke=18,be=40,qe=`${be}px`,ze=["[data-lastpass-icon-root]","com-1password-button","[data-dashlanecreated]",'[style$="2147483647 !important;"]'].join(",");function Qe({containerRef:n,inputRef:t,pushPasswordManagerStrategy:a,isFocused:o}){let[S,i]=e.useState(!1),[P,m]=e.useState(!1),[R,k]=e.useState(!1),M=e.useMemo(()=>a==="none"?!1:(a==="increase-width"||a==="experimental-no-flickering")&&S&&P,[S,P,a]),h=e.useCallback(()=>{let v=n.current,E=t.current;if(!v||!E||R||a==="none")return;let g=v,u=g.getBoundingClientRect().left+g.offsetWidth,_=g.getBoundingClientRect().top+g.offsetHeight/2,c=u-Ke,H=_;document.querySelectorAll(ze).length===0&&document.elementFromPoint(c,H)===v||(i(!0),k(!0))},[n,t,R,a]);return e.useEffect(()=>{let v=n.current;if(!v||a==="none")return;function E(){let u=window.innerWidth-v.getBoundingClientRect().right;m(u>=be)}E();let g=setInterval(E,1e3);return()=>{clearInterval(g)}},[n,a]),e.useEffect(()=>{let v=o||document.activeElement===t.current;if(a==="none"||!v)return;let E=setTimeout(h,0),g=setTimeout(h,2e3),u=setTimeout(h,5e3),_=setTimeout(()=>{k(!0)},6e3);return()=>{clearTimeout(E),clearTimeout(g),clearTimeout(u),clearTimeout(_)}},[t,o,a,h]),{hasPWMBadge:S,willPushPWMBadge:M,PWM_BADGE_SPACE_WIDTH:qe}}var ye=e.createContext({}),we=e.forwardRef((n,t)=>{var a=n,{value:o,onChange:S,maxLength:i,textAlign:P="left",pattern:m,placeholder:R,inputMode:k="numeric",onComplete:M,pushPasswordManagerStrategy:h="increase-width",pasteTransformer:v,containerClassName:E,noScriptCSSFallback:g=Ve,render:u,children:_}=a,c=He(a,["value","onChange","maxLength","textAlign","pattern","placeholder","inputMode","onComplete","pushPasswordManagerStrategy","pasteTransformer","containerClassName","noScriptCSSFallback","render","children"]),H,re,ae,le,oe;let[Se,Ce]=e.useState(typeof c.defaultValue=="string"?c.defaultValue:""),p=o??Se,D=$e(p),G=e.useCallback(r=>{S?.(r),Ce(r)},[S]),x=e.useMemo(()=>m?typeof m=="string"?new RegExp(m):m:null,[m]),d=e.useRef(null),Z=e.useRef(null),U=e.useRef({value:p,onChange:G,isIOS:typeof window<"u"&&((re=(H=window?.CSS)==null?void 0:H.supports)==null?void 0:re.call(H,"-webkit-touch-callout","none"))}),Q=e.useRef({prev:[(ae=d.current)==null?void 0:ae.selectionStart,(le=d.current)==null?void 0:le.selectionEnd,(oe=d.current)==null?void 0:oe.selectionDirection]});e.useImperativeHandle(t,()=>d.current,[]),e.useEffect(()=>{let r=d.current,l=Z.current;if(!r||!l)return;U.current.value!==r.value&&U.current.onChange(r.value),Q.current.prev=[r.selectionStart,r.selectionEnd,r.selectionDirection];function f(){if(document.activeElement!==r){K(null),q(null);return}let s=r.selectionStart,b=r.selectionEnd,V=r.selectionDirection,C=r.maxLength,A=r.value,T=Q.current.prev,j=-1,O=-1,F;if(A.length!==0&&s!==null&&b!==null){let Me=s===b,Te=s===A.length&&A.length<C;if(Me&&!Te){let N=s;if(N===0)j=0,O=1,F="forward";else if(N===C)j=N-1,O=N,F="backward";else if(C>1&&A.length>1){let te=0;if(T[0]!==null&&T[1]!==null){F=N<T[1]?"backward":"forward";let Re=T[0]===T[1]&&T[0]<C;F==="backward"&&!Re&&(te=-1)}j=te+N,O=te+N+1}}j!==-1&&O!==-1&&j!==O&&d.current.setSelectionRange(j,O,F)}let fe=j!==-1?j:s,me=O!==-1?O:b,ke=F??V;K(fe),q(me),Q.current.prev=[fe,me,ke]}if(document.addEventListener("selectionchange",f,{capture:!0}),f(),document.activeElement===r&&Y(!0),!document.getElementById("input-otp-style")){let s=document.createElement("style");if(s.id="input-otp-style",document.head.appendChild(s),s.sheet){let b="background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;";z(s.sheet,"[data-input-otp]::selection { background: transparent !important; color: transparent !important; }"),z(s.sheet,`[data-input-otp]:autofill { ${b} }`),z(s.sheet,`[data-input-otp]:-webkit-autofill { ${b} }`),z(s.sheet,"@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }"),z(s.sheet,"[data-input-otp] + * { pointer-events: all !important; }")}}let y=()=>{l&&l.style.setProperty("--root-height",`${r.clientHeight}px`)};y();let w=new ResizeObserver(y);return w.observe(r),()=>{document.removeEventListener("selectionchange",f,{capture:!0}),w.disconnect()}},[]);let[se,ie]=e.useState(!1),[$,Y]=e.useState(!1),[I,K]=e.useState(null),[B,q]=e.useState(null);e.useEffect(()=>{Ge(()=>{var r,l,f,y;(r=d.current)==null||r.dispatchEvent(new Event("input"));let w=(l=d.current)==null?void 0:l.selectionStart,s=(f=d.current)==null?void 0:f.selectionEnd,b=(y=d.current)==null?void 0:y.selectionDirection;w!==null&&s!==null&&(K(w),q(s),Q.current.prev=[w,s,b])})},[p,$]),e.useEffect(()=>{D!==void 0&&p!==D&&D.length<i&&p.length===i&&M?.(p)},[i,M,D,p]);let L=Qe({containerRef:Z,inputRef:d,pushPasswordManagerStrategy:h,isFocused:$}),ue=e.useCallback(r=>{let l=r.currentTarget.value.slice(0,i);if(l.length>0&&x&&!x.test(l)){r.preventDefault();return}typeof D=="string"&&l.length<D.length&&document.dispatchEvent(new Event("selectionchange")),G(l)},[i,G,D,x]),ce=e.useCallback(()=>{var r;if(d.current){let l=Math.min(d.current.value.length,i-1),f=d.current.value.length;(r=d.current)==null||r.setSelectionRange(l,f),K(l),q(f)}Y(!0)},[i]),pe=e.useCallback(r=>{var l,f;let y=d.current;if(!v&&(!U.current.isIOS||!r.clipboardData||!y))return;let w=r.clipboardData.getData("text/plain"),s=v?v(w):w;r.preventDefault();let b=(l=d.current)==null?void 0:l.selectionStart,V=(f=d.current)==null?void 0:f.selectionEnd,C=(b!==V?p.slice(0,b)+s+p.slice(V):p.slice(0,b)+s+p.slice(b)).slice(0,i);if(C.length>0&&x&&!x.test(C))return;y.value=C,G(C);let A=Math.min(C.length,i-1),T=C.length;y.setSelectionRange(A,T),K(A),q(T)},[i,G,x,p]),Ee=e.useMemo(()=>({position:"relative",cursor:c.disabled?"default":"text",userSelect:"none",WebkitUserSelect:"none",pointerEvents:"none"}),[c.disabled]),de=e.useMemo(()=>({position:"absolute",inset:0,width:L.willPushPWMBadge?`calc(100% + ${L.PWM_BADGE_SPACE_WIDTH})`:"100%",clipPath:L.willPushPWMBadge?`inset(0 ${L.PWM_BADGE_SPACE_WIDTH} 0 0)`:void 0,height:"100%",display:"flex",textAlign:P,opacity:"1",color:"transparent",pointerEvents:"all",background:"transparent",caretColor:"transparent",border:"0 solid transparent",outline:"0 solid transparent",boxShadow:"none",lineHeight:"1",letterSpacing:"-.5em",fontSize:"var(--root-height)",fontFamily:"monospace",fontVariantNumeric:"tabular-nums"}),[L.PWM_BADGE_SPACE_WIDTH,L.willPushPWMBadge,P]),xe=e.useMemo(()=>e.createElement("input",Le(Be({autoComplete:c.autoComplete||"one-time-code"},c),{"data-input-otp":!0,"data-input-otp-placeholder-shown":p.length===0||void 0,"data-input-otp-mss":I,"data-input-otp-mse":B,inputMode:k,pattern:x?.source,"aria-placeholder":R,style:de,maxLength:i,value:p,ref:d,onPaste:r=>{var l;pe(r),(l=c.onPaste)==null||l.call(c,r)},onChange:ue,onMouseOver:r=>{var l;ie(!0),(l=c.onMouseOver)==null||l.call(c,r)},onMouseLeave:r=>{var l;ie(!1),(l=c.onMouseLeave)==null||l.call(c,r)},onFocus:r=>{var l;ce(),(l=c.onFocus)==null||l.call(c,r)},onBlur:r=>{var l;Y(!1),(l=c.onBlur)==null||l.call(c,r)}})),[ue,ce,pe,k,de,i,B,I,c,x?.source,p]),ee=e.useMemo(()=>({slots:Array.from({length:i}).map((r,l)=>{var f;let y=$&&I!==null&&B!==null&&(I===B&&l===I||l>=I&&l<B),w=p[l]!==void 0?p[l]:null,s=p[0]!==void 0?null:(f=R?.[l])!=null?f:null;return{char:w,placeholderChar:s,isActive:y,hasFakeCaret:y&&w===null}}),isFocused:$,isHovering:!c.disabled&&se}),[$,se,i,B,I,c.disabled,p]),Pe=e.useMemo(()=>u?u(ee):e.createElement(ye.Provider,{value:ee},_),[_,ee,u]);return e.createElement(e.Fragment,null,g!==null&&e.createElement("noscript",null,e.createElement("style",null,g)),e.createElement("div",{ref:Z,"data-input-otp-container":!0,style:Ee,className:E},Pe,e.createElement("div",{style:{position:"absolute",inset:0,pointerEvents:"none"}},xe)))});we.displayName="Input";function z(n,t){try{n.insertRule(t)}catch{console.error("input-otp could not insert CSS rule:",t)}}var Ve=`
[data-input-otp] {
--nojs-bg: white !important;
--nojs-fg: black !important;
background-color: var(--nojs-bg) !important;
color: var(--nojs-fg) !important;
caret-color: var(--nojs-fg) !important;
letter-spacing: .25em !important;
text-align: center !important;
border: 1px solid var(--nojs-fg) !important;
border-radius: 4px !important;
width: 100% !important;
}
@media (prefers-color-scheme: dark) {
[data-input-otp] {
--nojs-bg: black !important;
--nojs-fg: white !important;
}
}`,nt="^\\d+$";const Je=e.forwardRef(({className:n,containerClassName:t,...a},o)=>W.jsx(we,{ref:o,containerClassName:J("flex items-center gap-2 has-[:disabled]:opacity-50",t),className:J("disabled:cursor-not-allowed",n),...a}));Je.displayName="InputOTP";const Xe=e.forwardRef(({className:n,...t},a)=>W.jsx("div",{ref:a,className:J("flex items-center",n),...t}));Xe.displayName="InputOTPGroup";const Ze=e.forwardRef(({index:n,className:t,...a},o)=>{const S=e.useContext(ye),{char:i,hasFakeCaret:P,isActive:m}=S.slots[n];return W.jsxs("div",{ref:o,className:J("relative flex h-9 w-9 items-center justify-center border-y border-r border-input text-sm shadow-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md",m&&"z-10 ring-1 ring-ring",t),...a,children:[i,P&&W.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:W.jsx("div",{className:"h-4 w-px animate-caret-blink bg-foreground duration-1000"})})]})});Ze.displayName="InputOTPSlot";const Ue=e.forwardRef(({...n},t)=>W.jsx("div",{ref:t,role:"separator",...n,children:W.jsx(Fe,{})}));Ue.displayName="InputOTPSeparator";const rt=6,ne=async n=>{const t=await fetch(n,{headers:{Accept:"application/json"}});if(!t.ok)throw new Error(`Failed to fetch: ${t.status}`);return t.json()},at=()=>{const[n,t]=e.useState(null),[a,o]=e.useState(null),[S,i]=e.useState([]),[P,m]=e.useState([]),R=e.useMemo(()=>n!==null&&a!==null,[n,a]),k=e.useCallback(async()=>{try{const{svg:u}=await ne(Oe.url());t(u)}catch{m(u=>[...u,"Failed to fetch QR code"]),t(null)}},[]),M=e.useCallback(async()=>{try{const{secretKey:u}=await ne(De.url());o(u)}catch{m(u=>[...u,"Failed to fetch a setup key"]),o(null)}},[]),h=e.useCallback(()=>{m([])},[]),v=e.useCallback(()=>{o(null),t(null),h()},[h]),E=e.useCallback(async()=>{try{h();const u=await ne(Ie.url());i(u)}catch{m(u=>[...u,"Failed to fetch recovery codes"]),i([])}},[h]),g=e.useCallback(async()=>{try{h(),await Promise.all([k(),M()])}catch{t(null),o(null)}},[h,k,M]);return{qrCodeSvg:n,manualSetupKey:a,recoveryCodesList:S,hasSetupData:R,errors:P,clearErrors:h,clearSetupData:v,fetchQrCode:k,fetchSetupKey:M,fetchSetupData:g,fetchRecoveryCodes:E}};export{Je as I,nt as K,rt as O,Xe as a,Ze as b,at as u};