{"version":3,"file":"SupabaseAuthOverrides.CCeZUqvr.mjs","names":["React","userData","error","session"],"sources":["https:/framerusercontent.com/modules/8GuC81thajy1SOAM5qio/gONZmjdCdNNeeU7PsSuC/SupabaseAuthOverrides.js"],"sourcesContent":["// SupabaseAuthOverrides.tsx\n// FIXED VERSION - Removed auto-authentication for localhost\nimport{jsx as _jsx}from\"react/jsx-runtime\";import React from\"react\";const SUPABASE_URL=\"https://effbelryguosqwlvsxud.supabase.co\";const SUPABASE_ANON_KEY=\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImVmZmJlbHJ5Z3Vvc3F3bHZzeHVkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTg2OTUyMTMsImV4cCI6MjA3NDI3MTIxM30.4MnG3Yj7ABNO0X6pC0Oc0wiD07YBSMVIi801LUYZVX0\";let supabaseInstance=null;let scriptLoadAttempted=false;let scriptLoadPromise=null;// FIXED: Better script loading\nfunction loadSupabaseScript(){if(typeof window===\"undefined\"){return Promise.resolve(null);}if(window.supabase&&window.supabase.createClient){return Promise.resolve(window.supabase);}if(scriptLoadPromise){return scriptLoadPromise;}scriptLoadPromise=new Promise(resolve=>{const script=document.createElement(\"script\");script.src=\"https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2/dist/umd/supabase.min.js\";script.async=true;script.crossOrigin=\"anonymous\";script.onload=()=>{console.log(\"Supabase loaded\");scriptLoadAttempted=true;resolve(window.supabase||null);};script.onerror=()=>{console.error(\"Failed to load Supabase script\");resolve(null);};document.head.appendChild(script);});return scriptLoadPromise;}// FIXED: Client creation\nasync function getSupabaseClient(){if(typeof window===\"undefined\")return null;if(supabaseInstance)return supabaseInstance;try{const supabaseLib=await loadSupabaseScript();if(supabaseLib&&supabaseLib.createClient){supabaseInstance=supabaseLib.createClient(SUPABASE_URL,SUPABASE_ANON_KEY,{auth:{persistSession:true,autoRefreshToken:true,detectSessionInUrl:true}});// Store globally so SignInForm can use it\nwindow.__supabase_client=supabaseInstance;return supabaseInstance;}}catch(error){console.error(\"Failed to create Supabase client:\",error);}return null;}// FIXED: Only return true for actual Framer canvas previews\nfunction isFramerCanvas(){if(typeof window===\"undefined\")return false;// Only show mock data in actual Framer canvas preview\n// Remove localhost:3000 unless you want previews there too\nreturn window.location.href.includes(\"framer.website\")||window.location.href.includes(\"framer.app\");}// SSR-safe component wrapper\nfunction createSSRSafeWrapper(WrapperComponent){return function SSRSafeWrapper(props){const[mounted,setMounted]=React.useState(false);React.useEffect(()=>{setMounted(true);},[]);if(!mounted){return null;}return /*#__PURE__*/_jsx(WrapperComponent,{...props});};}// FIXED: AuthWrapperInner - removed premature authentication\nfunction AuthWrapperInner(props){const[authState,setAuthState]=React.useState(\"loading\");const[userData,setUserData]=React.useState(null);const Component=props.Component;const wrapperType=props.wrapperType;const innerProps={...props};delete innerProps.Component;delete innerProps.wrapperType;React.useEffect(()=>{let mounted=true;let unsubscribe=null;const checkAuth=async()=>{if(!mounted)return;try{const supabase=await getSupabaseClient();if(!supabase){console.log(\"No Supabase client available\");// Check localStorage for existing session\nconst token=localStorage.getItem(\"sb-access-token\");const userEmail=localStorage.getItem(\"user_email\");if(token){// If we have a token, try to verify it\ntry{const response=await fetch(`${SUPABASE_URL}/auth/v1/user`,{headers:{Authorization:`Bearer ${token}`,apikey:SUPABASE_ANON_KEY}});if(response.ok){const userData=await response.json();setAuthState(\"authenticated\");setUserData(userData);}else{setAuthState(\"unauthenticated\");}}catch{setAuthState(\"unauthenticated\");}}else{setAuthState(\"unauthenticated\");}return;}// Get initial session - this is the key fix\nconsole.log(\"Getting session from Supabase...\");const{data:{session},error}=await supabase.auth.getSession();if(error){console.error(\"Session error:\",error);setAuthState(\"unauthenticated\");return;}console.log(\"Session data:\",session);if(session?.user){console.log(\"User authenticated:\",session.user.email);// Get user profile\ntry{const{data:profile,error:profileError}=await supabase.from(\"user_profiles\").select(\"plan\").eq(\"email\",session.user.email).single();if(!profileError&&profile){setUserData({...session.user,plan:profile.plan});}else{setUserData({...session.user,plan:\"free\"});}}catch(error){setUserData({...session.user,plan:\"free\"});}setAuthState(\"authenticated\");}else{console.log(\"No user session found\");setAuthState(\"unauthenticated\");}// Listen for auth changes\nif(supabase.auth?.onAuthStateChange){const{data:{subscription}}=supabase.auth.onAuthStateChange((event,session)=>{console.log(\"Auth state changed:\",event,session);if(!mounted)return;if(session?.user){setAuthState(\"authenticated\");setUserData({...session.user,plan:\"free\"});}else{setAuthState(\"unauthenticated\");setUserData(null);}});unsubscribe=()=>subscription.unsubscribe();}}catch(error){console.error(\"Auth check error:\",error);if(mounted){setAuthState(\"unauthenticated\");}}};// Only show mock data in Framer canvas preview\nif(isFramerCanvas()){if(mounted){// Still show as loading initially, then show mock\nsetTimeout(()=>{if(mounted&&wrapperType===\"loggedIn\"){setAuthState(\"authenticated\");setUserData({plan:\"paid\",email:\"preview@example.com\"});}else{setAuthState(\"unauthenticated\");}},500);}}else{// Real auth check for production\ncheckAuth();}return()=>{mounted=false;if(unsubscribe){unsubscribe();}};},[]);// FIXED: Better loading state handling\nconst shouldShow=(()=>{// In Framer canvas, respect the wrapperType\nif(isFramerCanvas()){if(authState===\"loading\")return false// Don't show while loading\n;if(wrapperType===\"loggedIn\")return authState===\"authenticated\";if(wrapperType===\"loggedOut\")return authState===\"unauthenticated\";if(wrapperType===\"paid\")return authState===\"authenticated\"&&userData?.plan===\"paid\";if(wrapperType===\"free\")return authState===\"unauthenticated\"||authState===\"authenticated\"&&userData?.plan!==\"paid\";return true;}// In production, handle loading state\nif(authState===\"loading\"){// Optionally show a loader or nothing\nreturn false;}switch(wrapperType){case\"loggedIn\":return authState===\"authenticated\";case\"loggedOut\":return authState===\"unauthenticated\";case\"paid\":return authState===\"authenticated\"&&userData?.plan===\"paid\";case\"free\":return authState===\"unauthenticated\"||authState===\"authenticated\"&&userData?.plan!==\"paid\";default:return true;}})();if(!shouldShow){return null;}const enhancedProps={...innerProps,...authState===\"authenticated\"&&userData?{user:userData}:{}};return /*#__PURE__*/_jsx(Component,{...enhancedProps});}// Export HOCs (same as before)\nexport function withLoggedIn(Component){const Wrapper=props=>/*#__PURE__*/_jsx(AuthWrapperInner,{...props,Component:Component,wrapperType:\"loggedIn\"});return createSSRSafeWrapper(Wrapper);}export function withLoggedOut(Component){const Wrapper=props=>/*#__PURE__*/_jsx(AuthWrapperInner,{...props,Component:Component,wrapperType:\"loggedOut\"});return createSSRSafeWrapper(Wrapper);}export function withPaidPlan(Component){const Wrapper=props=>/*#__PURE__*/_jsx(AuthWrapperInner,{...props,Component:Component,wrapperType:\"paid\"});return createSSRSafeWrapper(Wrapper);}export function withLoggedOutFreePlan(Component){const Wrapper=props=>/*#__PURE__*/_jsx(AuthWrapperInner,{...props,Component:Component,wrapperType:\"free\"});return createSSRSafeWrapper(Wrapper);}export function withActiveLicense(Component){return withPaidPlan(Component);}// Sign out button\nexport function withSignOut(Component){const SignOutWrapper=props=>{const[mounted,setMounted]=React.useState(false);React.useEffect(()=>{setMounted(true);},[]);const handleSignOut=async()=>{if(!mounted)return;try{const supabase=await getSupabaseClient();if(supabase?.auth?.signOut){await supabase.auth.signOut();}// Clear storage\nlocalStorage.clear();window.location.href=\"/\";}catch(error){console.error(\"Sign out error:\",error);window.location.href=\"/\";}};return /*#__PURE__*/_jsx(Component,{...props,onClick:handleSignOut});};return createSSRSafeWrapper(SignOutWrapper);}// Initialize on import\nif(typeof window!==\"undefined\"){// Start loading in background\nloadSupabaseScript().catch(()=>{console.log(\"Background script loading\");});}\nexport const __FramerMetadata__ = {\"exports\":{\"withSignOut\":{\"type\":\"reactComponent\",\"name\":\"withSignOut\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"withActiveLicense\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLoggedIn\":{\"type\":\"reactHoc\",\"name\":\"withLoggedIn\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLoggedOutFreePlan\":{\"type\":\"reactHoc\",\"name\":\"withLoggedOutFreePlan\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withPaidPlan\":{\"type\":\"reactHoc\",\"name\":\"withPaidPlan\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLoggedOut\":{\"type\":\"reactHoc\",\"name\":\"withLoggedOut\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SupabaseAuthOverrides.map"],"mappings":"gIAGA,SAAS,GAAoB,CAAipB,OAAtoB,IAAS,OAAoB,QAAQ,QAAQ,KAAK,CAAK,EAAO,UAAU,EAAO,SAAS,aAAqB,QAAQ,QAAQ,EAAO,SAAS,CAAK,IAA6C,EAAkB,IAAI,QAAQ,GAAS,CAAC,IAAM,EAAO,SAAS,cAAc,SAAS,CAAC,EAAO,IAAI,gFAAgF,EAAO,MAAM,GAAK,EAAO,YAAY,YAAY,EAAO,WAAW,CAAC,QAAQ,IAAI,kBAAkB,CAA0B,EAAQ,EAAO,UAAU,KAAK,EAAG,EAAO,YAAY,CAAC,QAAQ,MAAM,iCAAiC,CAAC,EAAQ,KAAK,EAAG,SAAS,KAAK,YAAY,EAAO,EAAG,CAAQ,GACrrB,eAAe,GAAmB,CAAC,GAAU,IAAS,OAAY,OAAO,KAAK,GAAG,EAAiB,OAAO,EAAiB,GAAG,CAAC,IAAM,EAAY,MAAM,GAAoB,CAAC,GAAG,GAAa,EAAY,aAC7J,MAD2K,GAAiB,EAAY,aAAa,EAAa,EAAkB,CAAC,KAAK,CAAC,eAAe,GAAK,iBAAiB,GAAK,mBAAmB,GAAK,CAAC,CAAC,CACzW,EAAO,kBAAkB,EAAwB,QAAyB,EAAM,CAAC,QAAQ,MAAM,oCAAoC,EAAM,CAAE,OAAO,KAClJ,SAAS,GAAgB,CAEzB,OAFoC,IAAS,OAAmB,GAEzD,EAAO,SAAS,KAAK,SAAS,iBAAiB,EAAE,EAAO,SAAS,KAAK,SAAS,aAAa,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