"use strict";var e=require("react"),r=require("./frame-BHa-PKpX.js"),t=require("./errors-CBapWvRs.js"),i=require("./internal-context-CdsQ3LEl.js");require("./paths-DizMb-lU.js"),require("ofetch");exports.useLoginToMiniApp=()=>{let{client:a,setAuthenticated:n,setUser:s}=i.usePrivyInternal();return{initLoginToMiniApp:e.useCallback((async()=>{let e=new r.FarcasterFramesFlow;if(!a)throw new t.PrivyClientError("Must initialize Privy client first.");return a.startAuthFlow(e),await e.init()}),[a]),loginToMiniApp:e.useCallback((async({message:e,signature:i})=>{if(!a)throw new t.PrivyClientError("Must initialize Privy client first.");if(!(a.authFlow instanceof r.FarcasterFramesFlow))throw new t.PrivyClientError("Must initialize Farcaster Mini App flow first.");let l=(e=>{let r=e.match(/farcaster:\/\/fid\/(\d+)/);return r&&r[1]?parseInt(r[1],10):null})(e);if(!l)throw new t.PrivyClientError("Invalid message format; could not parse Farcaster ID.");a.authFlow.setAuthData({message:e,signature:i,fid:l});let{user:o}=await a.authenticate();return o&&(s(o),n(!0)),o}),[a,s,n])}};
//# sourceMappingURL=farcaster.js.map
