import{jsx as o}from"react/jsx-runtime";import{useMemo as t,useState as e,useEffect as r,useRef as i}from"react";import{u as s}from"./context-BKnOUECq.mjs";import{u as m}from"./privy-context-Bi6vqCPc.mjs";import{u as n}from"./index-C5jxD-zy.mjs";import{V as c,a,b as p,t as l}from"./to-ui-error-C5L4eJlu.mjs";import"@privy-io/js-sdk-core";import"tinycolor2";import"@privy-io/are-addresses-equal";import"./internal-context-dfitw7Ot.mjs";import"./toViemAccount-4iGGrW4w.mjs";import"jose";import"eventemitter3";import"./index-BtwxknTg.mjs";import"zustand";import"viem";import"viem/utils";import"./errors-Dd6zfYtp.mjs";import"ofetch";import"./wallet-connect-58EobR5U.mjs";import"./getPublicClient-D4yNgeGy.mjs";import"viem/chains";import"react-device-detect";import"@coinbase/wallet-sdk";import"@walletconnect/ethereum-provider";import"./pkce-BinverJO.mjs";import"./paths-BH8W4zMc.mjs";import"./PrivyPluginContext-DA-yS5vO.mjs";import"js-cookie";import"@privy-io/ethereum";import"viem/accounts";import"mipd";import"@scure/base";import"./usePrivy-BhL-ltvm.mjs";import"./use-unlink-wallet-oAguM2-k.mjs";import"./get-entropy-details-for-user-BIWg0YxF.mjs";import"./user-D5cqJNp9.mjs";import"./modal-context-DBwfUxD-.mjs";import"@privy-io/popup";import"./events-context-BJ75xIIf.mjs";import"styled-components";import"./useActiveWallet-BEfvREjE.mjs";import"@headlessui/react";import"@privy-io/urls";import"./getEmbeddedConnectedWallet-Ba6LFHzY.mjs";import"./frame-DtizlaLu.mjs";import"@privy-io/routes";import"./use-deposit-address-BwThybOQ.mjs";import"x402/client";import"@privy-io/api-base";import"./use-sign-with-user-signer-CQI6hUH7.mjs";import"@heroicons/react/24/outline/DevicePhoneMobileIcon";import"@heroicons/react/24/outline/FingerPrintIcon";import"@heroicons/react/24/outline/PhoneIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"./ModalHeader-DffkxvO4.mjs";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"./ScreenLayout-Caq5mGD8.mjs";import"./Screen-D8KNyGVj.mjs";import"./index-Dq_xe9dz.mjs";import"./PinInput-B8vD-umi.mjs";import"@heroicons/react/24/outline/CalendarIcon";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"./StackedContainer-B2vaEl56.mjs";import"./useGetTokenPrice-ENX-6s3C.mjs";import"./useGetSolPrice-x7gfUIHJ.mjs";import"./TransactionDetails-BIrREalL.mjs";import"./WalletLink-B5NUjxf-.mjs";import"./ethers-VpbQV-TA.mjs";import"./getFormattedUsdFromLamports-B6EqSEho.mjs";import"./transaction-CnfuREWo.mjs";import"./Layouts-BlFm53ED.mjs";import"@heroicons/react/24/outline/ChevronDownIcon";const u=({onClose:u})=>{let{user:d}=m(),h=s(),j=t((()=>d?.mfaMethods.filter((o=>"passkey"!==o||!h.globalDisablePasskeys))??[]),[d?.mfaMethods,h.globalDisablePasskeys]),[f,v]=e(j[0]??null),{init:y,cancel:k,submit:g}=n(),[b,w]=e(!1),[x,C]=e(null),[I,P]=e();r((()=>{v(j[0]??null)}),[j]);let S=i(!1);async function M(o){P(void 0);try{if(!o||!f)return;await g(f,o),w(!0),P(void 0),u()}catch(o){throw l(o).error}}async function A(o){if("passkey"!==o)try{v(o),await y(o)}catch(o){console.error(o)}else try{v(o);let t=await y(o);if(!t)throw Error("something went wrong");C(t),await g(o,t),w(!0),P(void 0),u()}catch(o){P(l(o))}}r((()=>{!S.current&&f&&(S.current=!0,A(f).finally((()=>{S.current=!1})))}),[]);let B=()=>{v(null),P(void 0),k(),u()};return d?"passkey"===f?/*#__PURE__*/o(c,{account:d.linkedAccounts.filter((o=>"passkey"===o.type&&o.enrolledInMfa)).sort(((o,t)=>t.firstVerifiedAt.valueOf()-o.firstVerifiedAt.valueOf()))[0],submitSuccess:b,hasBlockingError:I?.isBlocking??!1,error:I?.error,onClose:B,onBack:()=>{v(null),P(void 0)},handleSubmit:()=>M(x).catch(P)}):f?/*#__PURE__*/o(a,{submitSuccess:b,hasBlockingError:I?.isBlocking??!1,handleSubmitCode:M,selectedMethod:f,onClose:B,onBack:j.length>1?()=>v(null):void 0}):/*#__PURE__*/o(p,{mfaMethods:j,onSelect:A,handleClose:B}):null};export{u as MfaVerifyFlowScreen,u as default};
//# sourceMappingURL=MfaVerifyFlowScreen-j5AlO3px.mjs.map
