"use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("./context-rs-ygOK2.js"),t=require("./modal-context-BgeioxwT.js"),s=require("./privy-context-UTJouJ1x.js"),o=require("./to-ui-error-BjAd4uFQ.js");require("@privy-io/js-sdk-core"),require("tinycolor2"),require("./internal-context-CdsQ3LEl.js"),require("@privy-io/are-addresses-equal"),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("styled-components"),require("./useActiveWallet-dTc6deka.js"),require("viem/utils"),require("./wallet-connect-BuohfvHK.js"),require("./errors-CBapWvRs.js"),require("ofetch"),require("./getPublicClient-CFd_sHBk.js"),require("viem"),require("viem/chains"),require("eventemitter3"),require("./events-context-Di6--rDg.js"),require("./index-Ub4KpwSY.js"),require("zustand"),require("react-device-detect"),require("./get-entropy-details-for-user-D63rM5_a.js"),require("./user-D2oPA-vS.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("./toViemAccount-CopJpCYv.js"),require("jose"),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("./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"),require("./index-BoiKFBqR.js"),require("mipd"),require("@scure/base"),require("./usePrivy-Dt4_yE6Q.js"),require("./use-unlink-wallet-DAxmY7kq.js"),require("@privy-io/popup"),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");const u={component:()=>{let{user:u}=s.usePrivyContext(),n=i.useAppConfig(),a=r.useMemo((()=>u?.mfaMethods.filter((e=>"passkey"!==e||!n.globalDisablePasskeys))??[]),[u?.mfaMethods,n.globalDisablePasskeys]),{data:c}=t.usePrivyModal(),[l,q]=r.useState(a[0]),[d,h]=r.useState(!1),[f,j]=r.useState(),[y,p]=r.useState();if(r.useEffect((()=>{q(a[0])}),[a]),!c?.mfaVerify)throw Error("Missing modal data for MFA verification screen.");let{onFailure:m,onSuccess:v,generateOptions:k,verifyTotpCode:g,verifyPasskey:S,verifySmsCode:w,sendSmsCode:x}=c.mfaVerify,C=async e=>{if("passkey"!==e)try{q(e),"sms"===e&&(q(e),await x()),"totp"===e&&q(e)}catch(e){console.error(e)}else try{q(e);let r=await k();if(!r)throw Error("something went wrong");j(r),await S(r),h(!0),p(void 0),v()}catch(e){p(o.toUIError(e))}},M=async e=>{p(void 0);try{if(!e||!l)return;if("passkey"===l){if(!f)throw Error("Missing passkey challenge");await S(f)}else"sms"===l?await w(e):"totp"===l&&await g(e);p(void 0),h(!0),v()}catch(e){throw o.toUIError(e).error}},P=()=>{y||!d?m(y?.error??Error("Canceled MFA verification.")):v()},b=r.useRef(!1);return r.useEffect((()=>{!b.current&&l&&(b.current=!0,C(l).finally((()=>{b.current=!1})))}),[open]),u?"passkey"===l?/*#__PURE__*/e.jsx(o.VerifyWithPasskey,{account:u.linkedAccounts.filter((e=>"passkey"===e.type&&e.enrolledInMfa)).sort(((e,r)=>r.firstVerifiedAt.valueOf()-e.firstVerifiedAt.valueOf()))[0],submitSuccess:d,hasBlockingError:y?.isBlocking??!1,error:y?.error,onClose:P,onBack:()=>{q(void 0),p(void 0)},handleSubmit:()=>M(f).catch(p)}):"sms"===l||"totp"===l?/*#__PURE__*/e.jsx(o.VerifyWithSmsOrTotpCode,{selectedMethod:l,submitSuccess:d,hasBlockingError:y?.isBlocking??!1,handleSubmitCode:M,onClose:P,onBack:a.length>1?()=>q(void 0):void 0}):/*#__PURE__*/e.jsx(o.VerifyMethodSelectionScreen,{mfaMethods:a,onSelect:C,handleClose:P}):null}};exports.MfaAuthVerifyFlowScreen=u,exports.default=u;
//# sourceMappingURL=MfaAuthVerifyFlowScreen-CN3CeL9W.js.map
