"use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("./context-rs-ygOK2.js"),t=require("./toViemAccount-CopJpCYv.js"),s=require("./errors-CBapWvRs.js"),o=require("./internal-context-CdsQ3LEl.js"),a=require("./index-BoiKFBqR.js"),u=require("./modal-context-BgeioxwT.js"),n=require("./privy-context-UTJouJ1x.js"),c=require("./SetWalletPasswordForm-B0uh0K47.js");require("@privy-io/js-sdk-core"),require("tinycolor2"),require("jose"),require("eventemitter3"),require("./index-Ub4KpwSY.js"),require("zustand"),require("viem"),require("viem/utils"),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("ofetch"),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("@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("@privy-io/are-addresses-equal"),require("./use-sign-with-user-signer-BhoaqeNG.js"),require("@heroicons/react/24/outline/ExclamationTriangleIcon"),require("./Layouts-D3TOcPhm.js"),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("./shared-h7omXu55.js"),require("@heroicons/react/24/outline/ArrowPathIcon"),require("@heroicons/react/24/outline/EyeIcon"),require("@heroicons/react/24/outline/EyeSlashIcon"),require("./Checkbox-DzxHC5tk.js"),require("@heroicons/react/24/outline/KeyIcon"),require("@heroicons/react/24/solid/CheckCircleIcon"),require("fast-password-entropy"),require("secure-password-utilities"),require("secure-password-utilities/wordlists"),require("@heroicons/react/24/outline/ArrowDownTrayIcon"),require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),require("@heroicons/react/24/outline/DocumentDuplicateIcon"),require("@heroicons/react/24/solid/XCircleIcon"),require("./ScreenHeader-CgYJ5Fmg.js");const l={component:()=>{let{navigate:l,data:d,onUserCloseViaDialogOrKeybindRef:q}=u.usePrivyModal(),h=i.useAppConfig(),[p,y]=r.useState(""),[w,v]=r.useState(!1),[m,j]=r.useState(),[f,C]=r.useState(null),{create:P}=a.useCreateWalletWithoutFallback(),{authenticated:g,user:x}=n.usePrivyContext(),{closePrivyModal:S,isNewUserThisSession:b,initializeWalletProxy:I}=o.usePrivyInternal(),{onSuccess:E,onFailure:A,callAuthOnSuccessOnClose:k,shouldCreateEth:W,shouldCreateSol:M}=d.createWallet,[U,O]=r.useState(null),T=new t.RunEffectOnce((async()=>{try{let e;if(W&&M)e=await P({recoveryMethod:"user-passcode",recoveryPassword:m,chainType:"ethereum",walletIndex:0,latestUser:x}),e=await P({chainType:"solana",walletIndex:0,latestUser:e.user});else if(M)e=await P({recoveryMethod:"user-passcode",recoveryPassword:m,chainType:"solana",walletIndex:0,latestUser:x});else{if(!W)throw Error("Invalid args to create wallet");e=await P({recoveryMethod:"user-passcode",recoveryPassword:m,chainType:"ethereum",walletIndex:0,latestUser:x})}O(e),b?l("EmbeddedWalletCreatedScreen"):(E(e),S({shouldCallAuthOnSuccess:k}))}catch(e){y(e.message)}}));r.useEffect((()=>{f||I(3e4).then((e=>C(e)))}),[f]),r.useEffect((()=>{if(!g||!x)return l("LandingScreen"),void A(Error("User must be authenticated before creating a Privy wallet"))}),[g]),q.current=()=>null;/*#__PURE__*/return e.jsx(c.SetWalletPasswordForm,{config:{initiatedBy:"automatic"},appName:h?.name||"privy",loading:!f,buttonLoading:w,buttonHideAnimations:!U&&w,isResettingPassword:!1,error:p,password:m||"",onClose:()=>{U&&"user-passcode"!==U.account.recoveryMethod?(A(new s.PrivyEmbeddedWalletError("User created a wallet but failed to set a password for it")),S({shouldCallAuthOnSuccess:!1})):U?(E(U),S({shouldCallAuthOnSuccess:k})):(A(new s.PrivyEmbeddedWalletError("User wallet creation failed")),S({shouldCallAuthOnSuccess:!1}))},onPasswordChange:j,onPasswordGenerate:()=>j(c.generatePassphrase()),onSubmit:async()=>(v(!0),T.execute().then((()=>new Promise((e=>setTimeout(e,250))))).finally((()=>v(!1))))})}};exports.EmbeddedWalletPasswordCreateScreen=l,exports.default=l;
//# sourceMappingURL=RecoveryPasswordCreateScreen-BA39Qemu.js.map
