"use strict";var e=require("./use-deposit-address-CVyd0fqP.js"),r=require("./errors-CBapWvRs.js"),t=require("./paths-DizMb-lU.js"),i=require("./context-rs-ygOK2.js"),s=require("./events-context-Di6--rDg.js"),o=require("./internal-context-CdsQ3LEl.js");require("react"),require("@privy-io/routes"),require("zustand"),require("./user-D2oPA-vS.js"),require("./modal-context-BgeioxwT.js"),require("react/jsx-runtime"),require("ofetch"),require("@privy-io/js-sdk-core"),require("tinycolor2");class n{async authenticate(){if(!this.api)throw new r.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(t.ssoAuthenticatePath,{})}catch(e){throw r.formatApiError(e)}}async link(){throw new r.PrivyClientError("Linking is not supported for the SSO token flow")}constructor(){this.meta={}}}exports.useDepositAddress=e.useDepositAddress,exports.useLoginWithSsoToken=function(){let e=i.useAppConfig(),t=s.useEmitPrivyEvent(),{client:u,setUser:a,setAuthenticated:c,setIsNewUser:h}=o.usePrivyInternal();return{loginWithSsoToken:async()=>{if(!e.id||!u)throw new r.PrivyClientError("SDK not yet ready");try{let e=new n;u.startAuthFlow(e);let i=await u.authenticate(),s=i.user,o=i.isNewUser??!1;if(!s)throw new r.PrivyClientError("Unable to authenticate with SSO response");return a(s),h(o),c(!0),t("login","onComplete",{user:s,isNewUser:o,wasAlreadyAuthenticated:!1,loginMethod:"sso",loginAccount:null}),s}catch(e){throw t("login","onError",e.privyErrorCode||r.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}}}};
//# sourceMappingURL=internal.js.map
