"use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("./context-rs-ygOK2.js"),t=require("./privy-context-UTJouJ1x.js"),s=require("./index-BoiKFBqR.js"),o=require("./to-ui-error-BjAd4uFQ.js");require("@privy-io/js-sdk-core"),require("tinycolor2"),require("@privy-io/are-addresses-equal"),require("./internal-context-CdsQ3LEl.js"),require("./toViemAccount-CopJpCYv.js"),require("jose"),require("eventemitter3"),require("./index-Ub4KpwSY.js"),require("zustand"),require("viem"),require("viem/utils"),require("./errors-CBapWvRs.js"),require("ofetch"),require("./wallet-connect-BuohfvHK.js"),require("./getPublicClient-CFd_sHBk.js"),require("viem/chains"),require("react-device-detect"),require("@coinbase/wallet-sdk"),require("@walletconnect/ethereum-provider"),require("./pkce-CmuJlEgn.js"),require("./paths-DizMb-lU.js"),require("./PrivyPluginContext-DsLtVhZA.js"),require("js-cookie"),require("@privy-io/ethereum"),require("viem/accounts"),require("mipd"),require("@scure/base"),require("./usePrivy-Dt4_yE6Q.js"),require("./use-unlink-wallet-DAxmY7kq.js"),require("./get-entropy-details-for-user-D63rM5_a.js"),require("./user-D2oPA-vS.js"),require("./modal-context-BgeioxwT.js"),require("@privy-io/popup"),require("./events-context-Di6--rDg.js"),require("styled-components"),require("./useActiveWallet-dTc6deka.js"),require("@headlessui/react"),require("@privy-io/urls"),require("./getEmbeddedConnectedWallet-D6YL2FS9.js"),require("./frame-BHa-PKpX.js"),require("@privy-io/routes"),require("./use-deposit-address-CVyd0fqP.js"),require("x402/client"),require("@privy-io/api-base"),require("./use-sign-with-user-signer-BhoaqeNG.js"),require("@heroicons/react/24/outline/DevicePhoneMobileIcon"),require("@heroicons/react/24/outline/FingerPrintIcon"),require("@heroicons/react/24/outline/PhoneIcon"),require("@heroicons/react/24/outline/ShieldCheckIcon"),require("./ModalHeader-Cpls13mi.js"),require("@heroicons/react/24/outline/ArrowLeftIcon"),require("@heroicons/react/24/outline/ArrowRightIcon"),require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),require("@heroicons/react/24/outline/XMarkIcon"),require("./ScreenLayout-DaFW0I3a.js"),require("./Screen-8NusMFtu.js"),require("./index-ByFhjjzH.js"),require("./PinInput-B12fA7pp.js"),require("@heroicons/react/24/outline/CalendarIcon"),require("@heroicons/react/24/outline/ExclamationTriangleIcon"),require("./StackedContainer-CM36po_U.js"),require("./useGetTokenPrice-kLl5cylh.js"),require("./useGetSolPrice-BOxa4idj.js"),require("./TransactionDetails-BlFm7wK6.js"),require("./WalletLink-Dxq-sK27.js"),require("./ethers-DEImj_8B.js"),require("./getFormattedUsdFromLamports-Mu2fqwL2.js"),require("./transaction-DjF5X-by.js"),require("./Layouts-D3TOcPhm.js"),require("@heroicons/react/24/outline/ChevronDownIcon");const u=({onClose:u})=>{let{user:n}=t.usePrivyContext(),c=i.useAppConfig(),a=r.useMemo((()=>n?.mfaMethods.filter((e=>"passkey"!==e||!c.globalDisablePasskeys))??[]),[n?.mfaMethods,c.globalDisablePasskeys]),[l,q]=r.useState(a[0]??null),{init:d,cancel:h,submit:j}=s.useMfa(),[f,y]=r.useState(!1),[p,v]=r.useState(null),[m,k]=r.useState();r.useEffect((()=>{q(a[0]??null)}),[a]);let g=r.useRef(!1);async function x(e){k(void 0);try{if(!e||!l)return;await j(l,e),y(!0),k(void 0),u()}catch(e){throw o.toUIError(e).error}}async function S(e){if("passkey"!==e)try{q(e),await d(e)}catch(e){console.error(e)}else try{q(e);let r=await d(e);if(!r)throw Error("something went wrong");v(r),await j(e,r),y(!0),k(void 0),u()}catch(e){k(o.toUIError(e))}}r.useEffect((()=>{!g.current&&l&&(g.current=!0,S(l).finally((()=>{g.current=!1})))}),[]);let w=()=>{q(null),k(void 0),h(),u()};return n?"passkey"===l?/*#__PURE__*/e.jsx(o.VerifyWithPasskey,{account:n.linkedAccounts.filter((e=>"passkey"===e.type&&e.enrolledInMfa)).sort(((e,r)=>r.firstVerifiedAt.valueOf()-e.firstVerifiedAt.valueOf()))[0],submitSuccess:f,hasBlockingError:m?.isBlocking??!1,error:m?.error,onClose:w,onBack:()=>{q(null),k(void 0)},handleSubmit:()=>x(p).catch(k)}):l?/*#__PURE__*/e.jsx(o.VerifyWithSmsOrTotpCode,{submitSuccess:f,hasBlockingError:m?.isBlocking??!1,handleSubmitCode:x,selectedMethod:l,onClose:w,onBack:a.length>1?()=>q(null):void 0}):/*#__PURE__*/e.jsx(o.VerifyMethodSelectionScreen,{mfaMethods:a,onSelect:S,handleClose:w}):null};exports.MfaVerifyFlowScreen=u,exports.default=u;
//# sourceMappingURL=MfaVerifyFlowScreen-BrL_oIyQ.js.map
