"use strict";var e=require("react"),r=require("@privy-io/js-sdk-core"),t=require("./internal-context-CdsQ3LEl.js"),i=require("./privy-context-UTJouJ1x.js"),a=require("./context-rs-ygOK2.js"),s=require("./errors-CBapWvRs.js"),n=require("./modal-context-BgeioxwT.js"),l=require("./use-sign-with-user-signer-BhoaqeNG.js");require("@privy-io/are-addresses-equal"),require("react/jsx-runtime"),require("tinycolor2"),require("ofetch");exports.useCreateWallet=()=>{let{refreshSessionAndUser:i,privy:a}=t.usePrivyInternal();return e.useMemo((()=>({async createWallet(e){let t=await r.create(a,{request:{chain_type:e.chainType}}),s=await i();if(!s)throw Error("User must be authenticated before creating a Privy wallet");return{user:s,wallet:t}}})),[i,a])},exports.useExportWallet=function(){let{user:r,getAccessToken:l}=i.usePrivyContext(),{walletProxy:o,openModal:d,client:u}=t.usePrivyInternal(),{setModalData:c}=n.usePrivyModal(),p=a.useAppConfig();return e.useMemo((()=>({exportWallet:e=>new Promise((async(t,a)=>{if(!r)return void a(new s.PrivyClientError("User must be authenticated before exporting their Privy wallet"));let n=i.getPrivyWalletWithAddress(r,e.address);n?i.getIsUnifiedWallet(n)?await l()?o?(c({connectWallet:{recoveryMethod:n.recoveryMethod,connectingWalletAddress:n.address,isUnifiedWallet:!0,onCompleteNavigateTo:"EmbeddedWalletKeyExportScreen",onFailure:a,shouldForceMFA:!0},keyExport:{appId:p.id,appClientId:p.appClientId,origin:u.apiUrl,address:n.address,uiOptions:e.uiOptions,hdWalletIndex:n.walletIndex,chainType:n.chainType,walletId:n.id,isUnifiedWallet:!0,imported:n.imported,onSuccess:t,onFailure:a}}),d("EmbeddedWalletConnectingScreen")):a(new s.PrivyClientError("Wallet not ready for export")):a(new s.PrivyClientError("Must have valid access token.")):a(Error("Export via extended-chains is only supported for unified stack wallets")):a(new s.PrivyClientError("User must have an embedded wallet."))}))})),[r,l,o,d,u,c,p])},exports.useSignRawHash=()=>{let{user:a}=i.usePrivyContext(),{privy:s}=t.usePrivyInternal(),{signWithUserSigner:n}=l.useSignWithUserSigner();return e.useMemo((()=>({async signRawHash({address:e,chainType:t,hash:l}){if(!a)throw Error("User must be authenticated before signing");let o=i.getAllPrivyWalletsForChainType(a,t).filter((e=>i.getIsUnifiedWallet(e))).find((r=>r.address===e));if(!o)throw Error("Wallet not found");let d=await r.rawSign(s,n,{wallet_id:o.id,params:{hash:l}});if(d.data&&"signature"in d.data&&"hex"===d.data.encoding)return{signature:d.data.signature};throw Error("Failed to sign")}})),[s,n,a])};
//# sourceMappingURL=extended-chains.js.map
