import{al as o,af as a,A as t}from"./DE-SIukw.js";import{m as n}from"./CFYXg6N-.js";import"./6Np5euiX.js";const r=({reloadOnLogout:r,logoutCallback:e,signUpCallbacks:s}={})=>{const{httpClient:i,dispatch:c,metricool:l}=o();return{signUpMutation:n({onMutate:()=>{s?.beforeSignUpCallback()},mutationFn:async o=>{const a=await t(l.google_recaptcha_key,"signup");return await i.setRoute("onboarding/create_account").setPayload({email:o.credentials.email,password:o.credentials.password,marketing:o.marketing,captcha:a,terms:o.terms}).post()},onSuccess:async o=>{s?.onSignUpSuccessCallback(o.data.onboarding,o.data.account)},onError:o=>{s?.onSignUpErrorCallback(),console.error(o)}}),finishOnboardingMutation:n({mutationFn:async o=>i.setRoute("onboarding/finish_onboarding").setPayload({blogId:o.id}).post(),onSuccess:o=>{c({dispatchType:"setOnboardingState",change:{metricool:{onboarding:{...o.data.onboarding}}}})},onError:o=>{console.error(o)}}),signInRedirectUrlMutation:n({mutationFn:async()=>i.setRoute("onboarding/oauth_redirect").get(),onSuccess:o=>{window.location=o.data.redirect_url},onError:o=>{console.error(o)}}),logoutMutation:n({mutationFn:async()=>i.setRoute("logout").post(),onSuccess:o=>{e&&e(),r?window.location.reload():(c({dispatchType:"setOnboardingState",change:{metricool:{onboarding:o.data}}}),c({dispatchType:"resetAccountData"}))},onError:o=>{console.error(o),a.error(o.message)}})}};export{r as u};
