{"version":3,"file":"GoogleAuth.DMFTLmdV.mjs","names":["useCallback"],"sources":["https:/framerusercontent.com/modules/HI8qSfzyrKLDo3SM9Hqu/EIi6bKt4HGOZDSS2SqJP/GoogleAuth.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useLayoutEffect,useCallback}from\"react\";const setToken=token=>{const expiration=new Date;expiration.setFullYear(2030);const domain=\"brain.fm\";document.cookie=`token=${token}; expires=${expiration.toUTCString()}; domain=${domain}`;try{if(window.amplitude){document.cookie=`deviceId=${window.amplitude.getDeviceId()}; expires=${expiration.toUTCString()}; domain=${domain}`;}}catch(error){console.error(\"setToken(): could not set device id\");}window.location.href=\"https://my.brain.fm/welcome\";};const trackEventWithProperties=async(event,properties)=>{if(!window.amplitude)return;try{await window.amplitude.track(event,properties).promise;}catch(error){console.error(\"logEventWithProperties(): failed to log in amplitude\");}};/**\n * These annotations control how your component sizes\n * Learn more: https://www.framer.com/developers/#code-components-auto-sizing\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */ export default function GoogleAuth(props){// This is a React component containing an Example component\n// - Replace <Example /> with your own code\n// - Find inspiration: https://www.framer.com/developers/\nconst handleGoogleSignUp=useCallback(async data=>{if(data.credential){try{const responseRaw=await fetch(`https://api.brain.fm/v2/auth/google-signup`,{method:\"POST\",body:JSON.stringify({accessToken:data.credential}),headers:{\"Content-Type\":\"application/json\"}});const response=await responseRaw.json();if(response.status===200){const meRaw=await fetch(`https://api.brain.fm/v2/users/me`,{method:\"GET\",headers:{Authorization:`Bearer ${response.result}`}});const me=await meRaw.json();try{window.amplitude.setUserId(me.result.user.id);window.amplitude.identify(new window.amplitude.Identify().set(\"email\",me.result.user.email));}catch(error){console.error(\"trackSignUpEvent(): failed to sign up in amplitude\");}await trackEventWithProperties(\"core_sign_up_success\",{core_sign_up_method:\"google\",core_sign_up_location:\"go.brain.fm\"});setToken(response.result);}else{var ref;if(((response===null||response===void 0?void 0:(ref=response.messages)===null||ref===void 0?void 0:ref[0])||\"\").includes(\"Account already exists\")){window.location.href=\"https://my.brain.fm\";}}}catch(error1){await trackEventWithProperties(\"core_sign_up_error\",{core_sign_up_method:\"google\",core_sign_up_location:\"go.brain.fm\"});if(((error1===null||error1===void 0?void 0:error1.message)||\"\").includes(\"Account already exists\")){window.location.href=\"https://my.brain.fm\";}}}else{console.error(\"An error occurred while authorizing with Google\");await trackEventWithProperties(\"core_sign_up_error\",{core_sign_up_method:\"google\",core_sign_up_location:\"go.brain.fm\"});}},[]);useLayoutEffect(()=>{const googleBtn=document.getElementById(\"google-button\");if(!googleBtn||!window.google)return;window.google.accounts.id.initialize({client_id:\"557603022520-l5ok0ij6ppub9h4ds94snd3ojphav69j.apps.googleusercontent.com\",callback:handleGoogleSignUp,context:\"signup\"});window.google.accounts.id.renderButton(googleBtn,{theme:\"filled_blue\",shape:\"pill\",size:\"large\",logo_alignment:\"left\"});},[]);return /*#__PURE__*/ _jsx(\"div\",{style:containerStyle,children:/*#__PURE__*/ _jsx(\"div\",{id:\"google-button\",style:buttonStyle})});};const containerStyle={};const buttonStyle={height:\"44px\"};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GoogleAuth\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./GoogleAuth.map"],"mappings":"kIAMI,SAAwB,EAAW,EAAM,CAG7C,IAAM,EAAmBA,EAAY,KAAM,IAAM,CAAC,GAAG,EAAK,WAAY,GAAG,CAA4L,IAAM,EAAS,MAAxL,MAAM,MAAM,6CAA6C,CAAC,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,YAAY,EAAK,WAAW,CAAC,CAAC,QAAQ,CAAC,eAAe,mBAAmB,CAAC,CAAC,EAAkC,MAAM,CAAC,GAAG,EAAS,SAAS,IAAI,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