{"version":3,"file":"Examples.CD45952p.mjs","names":["useStore","useState"],"sources":["https:/framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js","https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/zWwq6uD4spJ4Zz694Ss0/Ya5V7M9ZwVUQmXXgCfa8/Examples.js"],"sourcesContent":["import{useState,useEffect}from\"react\";import{Data,useObserveData}from\"framer\";export function createStore(state1){// Use Data so that a Preview reload resets the state\nconst dataStore=Data({state:Object.freeze({...state1})});// Create a set function that updates the state\nconst setDataStore=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(dataStore.state);}dataStore.state=Object.freeze({...dataStore.state,...newState});};// Store the initial state, copy the object if it's an object\nlet storeState=typeof state1===\"object\"?Object.freeze({...state1}):state1;// Keep a list of all the listeners, in the form of React hook setters\nconst storeSetters=new Set();// Create a set function that updates all the listeners / setters\nconst setStoreState=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(storeState);}storeState=typeof newState===\"object\"?Object.freeze({...storeState,...newState}):newState;// Update all the listeners / setters with the new value\nstoreSetters.forEach(setter=>setter(storeState));};// Create the actual hook based on everything above\nfunction useStore(){// Create the hook we are going to use as a listener\nconst[state,setState]=useState(storeState);// If we unmount the component using this hook, we need to remove the listener\n// @ts-ignore\nuseEffect(()=>{// But right now, we need to add the listener\nstoreSetters.add(setState);return()=>storeSetters.delete(setState);},[]);// If Data context exists, use Data, otherwise use vanilla React state\nif(useObserveData()===true){useObserveData();return[dataStore.state,setDataStore];}else{// Return the state and a function to update the central store\nreturn[state,setStoreState];}}return useStore;}\nexport const __FramerMetadata__ = {\"exports\":{\"createStore\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./createStore.map","/*\n * createStore (framer/store@1.0.1)\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js\"\n","import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";// Learn more: https://www.framer.com/developers/overrides/\nconst useStore=createStore({isLoggedIn:false,hasRoles:false});export function withCustomClick(Component){return /*#__PURE__*/forwardRef((props,ref)=>{return /*#__PURE__*/_jsx(Component,{ref:ref,...props,href:props.link,onClick:()=>{window.location.pathname=props.link;}});});}export function hideIfLoggedIn(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store]=useStore();return store.isLoggedIn?null:/*#__PURE__*/_jsx(Component,{ref:ref,...props,href:props.link,onClick:()=>{window.location.pathname=props.link;}});});}export function withLoggedIn(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useStore();useEffect(()=>{fetch(\"/api/auth/get-session\",{credentials:\"include\"}).then(async val=>{const user=await val.json().then(data=>data?.user);let hasRoles=false;let isPaid=false;if(user){if(\"posthog\"in window){posthog?.identify(user.id,{email:user.email,name:user.name}// optional: set additional person properties\n);}let isPaid=false;try{const resp=await fetch(\"/api/trpc/user.getCompanyAccessesSummary\");const roles=await resp.json();for(const role of roles.result.data.json){const currPlan=role.subscription?.plan?.toLowerCase();if(currPlan!==\"basic\"&&currPlan!==\"light\"){isPaid=true;}// if (\n//     \"posthog\" in window &&\n//     window.location.hostname.endsWith(\n//         \"vouch.careers\"\n//     )\n// ) {\n//     posthog?.capture(\"$groupidentify\", {\n//         $group_type: \"company\",\n//         $group_key: role.id,\n//         $group_set: {\n//             name: role.name,\n//             subscription: role.subscription?.plan,\n//             subscriptionPeriod:\n//                 role.subscription\n//                     ?.subscriptionPeriod,\n//         },\n//     })\n// }\n}hasRoles=roles.result.data.json.length>0;}catch{}if(\"posthog\"in window){posthog?.identify(user.id,{email:user.email,name:user.name,isCompanyUser:hasRoles,isPaid:isPaid}// optional: set additional person properties\n);}}setStore({isLoggedIn:!!user,hasRoles});});},[]);const href=store.isLoggedIn?store.hasRoles?\"/profile/business\":\"/profile/candidate\":props.link;return /*#__PURE__*/_jsx(Component,{ref:ref,...props,title:store.isLoggedIn?store.hasRoles?\"Dashboard\":\"My Profile\":props.title,href:href,onClick:()=>{window.location.pathname=href;}});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withCustomClick\":{\"type\":\"reactHoc\",\"name\":\"withCustomClick\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLoggedIn\":{\"type\":\"reactHoc\",\"name\":\"withLoggedIn\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"hideIfLoggedIn\":{\"type\":\"reactHoc\",\"name\":\"hideIfLoggedIn\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Examples.map"],"mappings":"uMAA8E,SAAgB,EAAY,EAAO,CACjH,IAAM,EAAU,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAG,EAAO,CAAC,CAAC,CAAC,CAClD,EAAa,GAAU,CAC1B,OAAO,GAAW,aAAY,EAAS,EAAS,EAAU,MAAM,EAAE,EAAU,MAAM,OAAO,OAAO,CAAC,GAAG,EAAU,MAAM,GAAG,EAAS,CAAC,EAChI,EAAW,OAAO,GAAS,SAAS,OAAO,OAAO,CAAC,GAAG,EAAO,CAAC,CAAC,EAC7D,EAAa,IAAI,IACjB,EAAc,GAAU,CAC3B,OAAO,GAAW,aAAY,EAAS,EAAS,EAAW,EAAE,EAAW,OAAO,GAAW,SAAS,OAAO,OAAO,CAAC,GAAG,EAAW,GAAG,EAAS,CAAC,CAAC,EACjJ,EAAa,QAAQ,GAAQ,EAAO,EAAW,CAAC,EAChD,SAASA,GAAU,CACnB,GAAK,CAAC,EAAM,GAAUC,EAAS,EAAW,CAK1C,OAHA,OACA,EAAa,IAAI,EAAS,KAAW,EAAa,OAAO,EAAS,EAAG,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