{"version":3,"file":"Outseta.DjV2EOlK.mjs","names":["useState","user"],"sources":["https:/framerusercontent.com/modules/gkef1zdBsvObttsXafvK/7RsGJXRImdbPdL54OCEd/Outseta.js"],"sourcesContent":["/// VERSION 0.0.2\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";/////////////////// Button Overrides\nexport function withRegisterPopup(Component){return props=>{return /*#__PURE__*/_jsx(Component,{...props,\"data-o-anonymous\":\"1\",\"data-o-auth\":\"1\",\"data-mode\":\"popup\",\"data-widget-mode\":\"register\"});};}export function asLoginPopupButton(Component){return props=>{return /*#__PURE__*/_jsx(Component,{...props,\"data-o-anonymous\":\"1\",\"data-o-auth\":\"1\",\"data-mode\":\"popup\",\"data-widget-mode\":\"login\"});};}export function asProfilePopupButton(Component){return props=>{return /*#__PURE__*/_jsx(Component,{...props,\"data-o-authenticated\":\"1\",\"data-o-profile\":\"1\",\"data-mode\":\"popup\"});};}export function asLogoutButton(Component){return props=>{return /*#__PURE__*/_jsx(Component,{...props,\"data-o-authenticated\":\"1\",\"data-o-logout-link\":\"1\"});};}/////////////////// Visibility Overrides\nexport function showForAuthenticated(Component){return props=>{return /*#__PURE__*/_jsx(Component,{...props,\"data-o-authenticated\":\"1\"});};}export function showForAnonymous(Component){return props=>{return /*#__PURE__*/_jsx(Component,{...props,\"data-o-anonymous\":\"1\"});};}/////////// Visibility Overrides Based on Plan Uid\nexport function showForSinglePlan_aWxYEbmV(Component){const validPlanUid=\"aWxYEbmV\";return props=>{try{const user=useUser();const value=user&&user[\"Account.CurrentSubscription.Plan.Uid\"];if(value===validPlanUid){return /*#__PURE__*/_jsx(Component,{...props});}return null;}catch(error){log(\"error in showForSinglePlan\",validPlanUid,error?.message);return null;}};}/////////// Visibility Based on an Account Custom Property\nexport function showForPartyAccounts(Component){const validPropertyValue=\"PARTY\";return props=>{try{const user=useUser();const value=user&&user[\"Account.MyCustomAccountProperty\"]?.toUpperCase();if(value===validPropertyValue){return /*#__PURE__*/_jsx(Component,{...props});}return null;}catch(error){log(\"error in showForPartyPlan\",validPropertyValue,error?.message);return null;}};}/////////// Visibility Based on a Person Custom Property\nexport function showForPartyPeople(Component){const validPropertyValue=\"PARTY\";return props=>{try{const user=useUser();const value=user&&user[\"MyCustomPersonProperty\"]?.toUpperCase();if(value===validPropertyValue){return /*#__PURE__*/_jsx(Component,{...props});}return null;}catch(error){log(\"error in showForPartyPeople\",validPropertyValue,error?.message);return null;}};}/////////////////// Text Overrides\nexport function withUserFirstName(Component){return withProperty(\"FirstName\",Component);}export function withUserLastName(Component){return withProperty(\"LastName\",Component);}export function withUserFullName(Component){return withProperty(\"FullName\",Component);}export function withUserEmail(Component){return withProperty(\"Email\",Component);}export function withAccountName(Component){return withProperty(\"Account.Name\",Component);}export function withAccountSubscriptionUid(Component){return withProperty(\"Account.CurrentSubscription.Plan.Uid\",Component);}export function withAccountSubscriptionName(Component){return withProperty(\"Account.CurrentSubscription.Plan.Name\",Component);}export function withAccountSubscriptionDescription(Component){return withProperty(\"Account.CurrentSubscription.Plan.Description\",Component);}// ===== Custom Account string fields =====\nexport function withAccountSectors(Component){// System name: Sectors -> Account.Sectors\nreturn withProperty(\"Account.Sectors\",Component);}export function withAccountPlanType(Component){// System name: PlanType -> Account.PlanType\nreturn withProperty(\"Account.PlanType\",Component);}export function withAccountSizeWallet(Component){// System name: Size_wallet -> Account.Size_wallet\nreturn withProperty(\"Account.Size_wallet\",Component);}export function withAccountDealPipelineStage(Component){// System name: DealPipelineStage -> Account.DealPipelineStage\nreturn withProperty(\"Account.DealPipelineStage\",Component);}export function withAccountOpportunitiesOfInterest(Component){// System name: OpportunitiesOfInterest -> Account.OpportunitiesOfInterest\nreturn withProperty(\"Account.OpportunitiesOfInterest\",Component);}export function withAccountTypeOfAttention(Component){// System name: TypeOfAttention -> Account.TypeOfAttention\nreturn withProperty(\"Account.TypeOfAttention\",Component);}/////////////////// Image Overrides\nexport function withUserAvatar(Component){return withImageProperty(\"ProfileImageS3Url\",Component);}let user=null;const listeners=new Set;const fetchUser=async event=>{try{log(\"fetch user\",event);const out=getOutseta();if(!out)return;const userObject=await out.getUser();user=flattenObject(userObject);log(\"fetch user fulfilled\",event,userObject,user);notifyListeners();}catch(error){log(\"fetch user failed\",error?.message??error);}};const clearUser=event=>{user=null;log(\"cleared user\",event);notifyListeners();};const notifyListeners=()=>{listeners.forEach(listener=>listener(user));};export const subscribe=listener=>{listeners.add(listener);return()=>listeners.delete(listener);};export const getUser=()=>user;// Listen to global events that might change the user\nconst outsetaFetchUserEvents=[\"accessToken.set\",\"profile.update\",\"account.update\"];// Listen to global events that should clear the user\nconst outsetaClearUserEvents=[\"logout\"];if(typeof window!==\"undefined\"){const registerOutsetaEvents=()=>{const out=getOutseta();if(!out)return;outsetaFetchUserEvents.forEach(event=>{out.on(event,()=>fetchUser(event));});outsetaClearUserEvents.forEach(event=>{out.on(event,()=>clearUser(event));});};if(window.Outseta){registerOutsetaEvents();}else{window.addEventListener(\"load\",registerOutsetaEvents);}}/////////////////// User Hook\nfunction useUser(){const[userState,setUserState]=useState(getUser());useEffect(()=>{const updateData=newData=>setUserState(newData);const unsubscribe=subscribe(updateData);return()=>{unsubscribe();};},[]);return userState;}function getOutseta(){if(typeof window===\"undefined\"){// Rendering on the server\nreturn null;}const out=window.Outseta;if(!out){console.log(\"Outseta is missing or not loaded yet (maybe in Framer editor or before script load).\");return null;}return out;}/////////////////// Helpers\nfunction withProperty(property,Component){return props=>{const user=useUser();if(!user)return null;return /*#__PURE__*/_jsx(Component,{...props,text:user[property]});};}function withImageProperty(property,Component){return props=>{const user=useUser();if(!user)return null;const imageSrc=user[property];log(\"avatar source\",user[property]);if(imageSrc){return /*#__PURE__*/_jsx(Component,{...props,background:{...props.background,src:imageSrc,srcSet:undefined}});}else if(props.background?.src){// Component has image set, use as fallback\nreturn /*#__PURE__*/_jsx(Component,{...props});}else{// Component has no image set, remove\nreturn null;}};}function log(...props){const out=getOutseta();if(!out)return;out.debug(\"outseta.framer.override.user\",...props);}function flattenObject(obj,parent=\"\",res={}){for(let key in obj){const propName=parent?`${parent}.${key}`:key;if(Array.isArray(obj[key])){obj[key].forEach((item,index)=>{flattenObject(item,`${propName}[${index}]`,res);});}else if(typeof obj[key]===\"object\"&&obj[key]!==null){flattenObject(obj[key],propName,res);}else{res[propName]=obj[key];}}return res;}\nexport const __FramerMetadata__ = {\"exports\":{\"withAccountDealPipelineStage\":{\"type\":\"reactHoc\",\"name\":\"withAccountDealPipelineStage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountSectors\":{\"type\":\"reactHoc\",\"name\":\"withAccountSectors\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserFirstName\":{\"type\":\"reactHoc\",\"name\":\"withUserFirstName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountSubscriptionDescription\":{\"type\":\"reactHoc\",\"name\":\"withAccountSubscriptionDescription\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountSubscriptionUid\":{\"type\":\"reactHoc\",\"name\":\"withAccountSubscriptionUid\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountPlanType\":{\"type\":\"reactHoc\",\"name\":\"withAccountPlanType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountOpportunitiesOfInterest\":{\"type\":\"reactHoc\",\"name\":\"withAccountOpportunitiesOfInterest\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"asLogoutButton\":{\"type\":\"reactHoc\",\"name\":\"asLogoutButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"subscribe\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserAvatar\":{\"type\":\"reactHoc\",\"name\":\"withUserAvatar\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForSinglePlan_aWxYEbmV\":{\"type\":\"reactHoc\",\"name\":\"showForSinglePlan_aWxYEbmV\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserLastName\":{\"type\":\"reactHoc\",\"name\":\"withUserLastName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountTypeOfAttention\":{\"type\":\"reactHoc\",\"name\":\"withAccountTypeOfAttention\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"asProfilePopupButton\":{\"type\":\"reactHoc\",\"name\":\"asProfilePopupButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getUser\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRegisterPopup\":{\"type\":\"reactHoc\",\"name\":\"withRegisterPopup\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountSubscriptionName\":{\"type\":\"reactHoc\",\"name\":\"withAccountSubscriptionName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountSizeWallet\":{\"type\":\"reactHoc\",\"name\":\"withAccountSizeWallet\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountName\":{\"type\":\"reactHoc\",\"name\":\"withAccountName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserFullName\":{\"type\":\"reactHoc\",\"name\":\"withUserFullName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForPartyPeople\":{\"type\":\"reactHoc\",\"name\":\"showForPartyPeople\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserEmail\":{\"type\":\"reactHoc\",\"name\":\"withUserEmail\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForAnonymous\":{\"type\":\"reactHoc\",\"name\":\"showForAnonymous\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForPartyAccounts\":{\"type\":\"reactHoc\",\"name\":\"showForPartyAccounts\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForAuthenticated\":{\"type\":\"reactHoc\",\"name\":\"showForAuthenticated\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"asLoginPopupButton\":{\"type\":\"reactHoc\",\"name\":\"asLoginPopupButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"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