1import{ei as T,ej as I,d8 as a,fn as M,eS as W,ek as j,d9 as R,fd as k,fp as v}from"./index-I4Bd4QeM.js";import{u as L,o as $}from"./SetWalletPasswordForm-B3EVuPZv-DVdAid_g.js";import"./ExclamationTriangleIcon-Dn6DlNWf.js";import"./Layouts-BMRfo5hw-BSc0WGOr.js";import"./ModalFooter-DKyozrEX-BzUQ78VB.js";import"./shared-DEkT-Gv3-BAzPuU55.js";import"./Checkbox-D1EDeo41-DL2wVlO0.js";import"./CheckCircleIcon-CyZU73DK.js";import"./ScreenHeader-CHmc4-Lu-DzOciIl9.js";const q={component:()=>{let{navigate:c,data:g,onUserCloseViaDialogOrKeybindRef:C}=T(),n=I(),[x,P]=a.useState(""),[d,h]=a.useState(!1),[t,f]=a.useState(),[i,b]=a.useState(null),{create:r}=M(),{authenticated:p,user:o}=W(),{closePrivyModal:l,isNewUserThisSession:E,initializeWalletProxy:U}=j(),{onSuccess:m,onFailure:u,callAuthOnSuccessOnClose:w,shouldCreateEth:y,shouldCreateSol:S}=g.createWallet,[s,O]=a.useState(null),A=new k((async()=>{try{let e;if(y&&S)e=await r({recoveryMethod:"user-passcode",recoveryPassword:t,chainType:"ethereum",walletIndex:0,latestUser:o}),e=await r({chainType:"solana",walletIndex:0,latestUser:e.user});else if(S)e=await r({recoveryMethod:"user-passcode",recoveryPassword:t,chainType:"solana",walletIndex:0,latestUser:o});else{if(!y)throw Error("Invalid args to create wallet");e=await r({recoveryMethod:"user-passcode",recoveryPassword:t,chainType:"ethereum",walletIndex:0,latestUser:o})}O(e),E?c("EmbeddedWalletCreatedScreen"):(m(e),l({shouldCallAuthOnSuccess:w}))}catch(e){P(e.message)}}));return a.useEffect((()=>{i||U(3e4).then((e=>b(e)))}),[i]),a.useEffect((()=>{if(!p||!o)return c("LandingScreen"),void u(Error("User must be authenticated before creating a Privy wallet"))}),[p]),C.current=()=>null,R.jsx(L,{config:{initiatedBy:"automatic"},appName:(n==null?void 0:n.name)||"privy",loading:!i,buttonLoading:d,buttonHideAnimations:!s&&d,isResettingPassword:!1,error:x,password:t||"",onClose:()=>{s&&s.account.recoveryMethod!=="user-passcode"?(u(new v("User created a wallet but failed to set a password for it")),l({shouldCallAuthOnSuccess:!1})):s?(m(s),l({shouldCallAuthOnSuccess:w})):(u(new v("User wallet creation failed")),l({shouldCallAuthOnSuccess:!1}))},onPasswordChange:f,onPasswordGenerate:()=>f($()),onSubmit:async()=>(h(!0),A.execute().then((()=>new Promise((e=>setTimeout(e,250))))).finally((()=>h(!1))))})}};export{q as EmbeddedWalletPasswordCreateScreen,q as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.