1import{d7 as a,e5 as $,dy as k,dw as U,dx as j,ev as R,ew as L,da as T,ex as V,eu as p}from"./JPxLSbkry-VDCYml.js";import{u as D,o as W}from"./6nMAZ4xWj1BYESds.js";import"./DknqV7AoD04p5CUF.js";import"./B7RaHNmUEtgE7InC.js";import"./CjQahFXYn1vLeR4c.js";import"./sNdgVEVHWuHwkOTF.js";import"./CWyx19A88XcvZekb.js";import"./v15TJUjLnPl6SdvN.js";import"./CMRxg9Wvp7vq3AvW.js";const X={component:()=>{let[n,A]=a.useState(null),[b,y]=a.useState(!1),[l,o]=a.useState(null),[i,v]=a.useState(""),{authenticated:h,user:c}=$(),{client:x,walletProxy:m,refreshSessionAndUser:P,closePrivyModal:d,createAnalyticsEvent:r}=k(),{navigate:S,data:E,onUserCloseViaDialogOrKeybindRef:C}=U(),N=j(),{onSuccess:f,onFailure:u}=E.setWalletPassword,e=R(c),g=n?.recoveryMethod==="user-passcode",t=e?.recoveryMethod==="user-passcode";a.useEffect((()=>{h||(S("LandingScreen"),u(new L("User must be authenticated before setting a password on a Privy wallet")))}),[h]);let w=()=>l?(u(l),void d({shouldCallAuthOnSuccess:!1})):g?(f(n),void d({shouldCallAuthOnSuccess:!1})):(u(new p("Exited before password was added to wallet")),void d({shouldCallAuthOnSuccess:!1}));return C.current=w,T.jsx(D,{appName:N?.name||"privy",config:{initiatedBy:"user",onCancel:w},error:l?"An error has occurred, please try again.":void 0,buttonLoading:b,buttonHideAnimations:!1,password:i,isResettingPassword:t,onPasswordGenerate:()=>v(W()),onPasswordChange:v,onSubmit:async()=>{g?(f(n),d({shouldCallAuthOnSuccess:!1})):(y(!0),o(null),await(async()=>{let _=await x.getAccessToken();if(_&&c&&e?.address&&i&&m)try{r({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:e.address,existingRecoveryMethod:e.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:t}});let{entropyId:s,entropyIdVerifier:I}=V(c);if(!(await m.setRecovery({accessToken:_,entropyId:s,entropyIdVerifier:I,recoveryPassword:i,recoveryMethod:"user-passcode"})).entropyId)return o(new p("Error setting password on privy wallet")),void r({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:e.address,existingRecoveryMethod:e.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:t,reason:"error setting password"}});let O=await P(),M=R(O);if(!M)return o(new p("Error setting password on privy wallet")),void r({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:e.address,existingRecoveryMethod:e.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:t,reason:"wallet disconnected"}});A(M),r({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:e.address,existingRecoveryMethod:e.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:t}})}catch(s){console.warn(s),o(s instanceof Error?s:Error("Error setting password on privy wallet")),r({eventName:"embedded_wallet_set_password_failed",payload:{walletAddress:e.address,reason:s}})}})(),y(!1))},onClose:w})}};export{X as EmbeddedWalletPasswordUpdateScreen,X 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.