{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/i94QUZXSTktuJHPDI4Gn/0lRKJSlJ2QqpLY1N9dJT/FramerAuth.js"],
  "sourcesContent": ["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{useRouter,inferInitialRouteFromPath}from\"framer\";import{auth}from\"https://cdn.framerauth.com/scripts/framerauth-sdk@beta.js\";const useStore=createStore({user:null,isAuthenticated:false,isLoaded:false});export function withAuth(Component){return props=>{const[store,setStore]=useStore();useEffect(()=>{if(!store.isAuthenticated){auth.getUser({cache:false}).then(({data,error})=>{const{user}=data;if(user){setStore({user:user,isAuthenticated:true,isLoaded:true});}else{setStore({isLoaded:true});}});}},[]);return /*#__PURE__*/_jsx(Component,{...props,store:store});};}export function withStore(Component){return props=>{const[store,setStore]=useStore();return /*#__PURE__*/_jsx(Component,{...props,store:store});};}export function withSignOut(Component){const handleClick=()=>{auth.signOut(\"/\");};return props=>{const[store,setStore]=useStore();if(!store.user)return null;return /*#__PURE__*/_jsx(Component,{...props,onClick:handleClick});};}export function withEmail(Component){return props=>{const[store,setStore]=useStore();if(!store.user)return null;return /*#__PURE__*/_jsx(Component,{...props,text:store.user.email});};}export function withFirstName(Component){return props=>{const[store,setStore]=useStore();if(!store.user)return null;return /*#__PURE__*/_jsx(Component,{...props,text:store.user.first_name});};}export function withLoggedIn(Component){return props=>{const[store,setStore]=useStore();if(!store.user)return null;return /*#__PURE__*/_jsx(Component,{...props});};}export function withLoggedOut(Component){return props=>{const[store]=useStore();if(store.user)return null;let className=props.className||\"\";if(!store.isLoaded){className+=\" fa-cloak\";}return /*#__PURE__*/_jsx(Component,{...props,className:className.trim()});};}export function withActiveLicense(Component){return props=>{var _store_user;const[store]=useStore();const hasActiveLicense=(_store_user=store.user)===null||_store_user===void 0?void 0:_store_user.licenses.some(license=>license.status===\"active\");if(!hasActiveLicense)return null;return /*#__PURE__*/_jsx(Component,{...props});};}export function withNoActiveLicense(Component){return props=>{var _store_user;const[store]=useStore();const hasActiveLicense=(_store_user=store.user)===null||_store_user===void 0?void 0:_store_user.licenses.some(license=>license.status===\"active\");if(hasActiveLicense)return null;return /*#__PURE__*/_jsx(Component,{...props});};}export function withVariant(Component){return props=>{const[store]=useStore();const variant=store.user?null:props===null||props===void 0?void 0:props.variant;return /*#__PURE__*/_jsx(Component,{...props,variant:variant});};}export function withVariantActiveLicense(Component){return props=>{var _store_user;const[store]=useStore();const hasActiveLicense=(_store_user=store.user)===null||_store_user===void 0?void 0:_store_user.licenses.some(license=>license.status===\"active\");const variant=hasActiveLicense?null:props===null||props===void 0?void 0:props.variant;return /*#__PURE__*/_jsx(Component,{...props,variant:variant});};}export function withIsLessonComplete(Component){return props=>{var _store_user_data,_store_user;const[store,setStore]=useStore();// Do not display the component if the user is logged out\nif(!store.user)return null;const key=`course:status:${props===null||props===void 0?void 0:props.slug}`;const isCompleted=((_store_user=store.user)===null||_store_user===void 0?void 0:(_store_user_data=_store_user.data)===null||_store_user_data===void 0?void 0:_store_user_data[key])===\"completed\";if(!isCompleted)return null;return /*#__PURE__*/_jsx(Component,{...props});};}export function withActionCompleteLesson(Component){return props=>{var _store_user_data,_store_user;const router=useRouter();const[store,setStore]=useStore();const key=`course:status:${props===null||props===void 0?void 0:props.slug}`;let isCompleted=((_store_user=store.user)===null||_store_user===void 0?void 0:(_store_user_data=_store_user.data)===null||_store_user_data===void 0?void 0:_store_user_data[key])===\"completed\";// Do not display the component if the user is logged out\nif(!store.user)return null;// Define an async function handleClick to handle the click event.\nconst handleClick=async event=>{try{// If the lesson has been completed exit the function\nif(isCompleted)return;// Update the components local state (for instant UI update)\nisCompleted=true;// Call the FramerAuth API to update the user data, marking the course as completed.\nconst{data,error}=await auth.patchUserData({[key]:\"completed\"});// If there is an error throw it.\nif(error){throw new Error(\"Error updating course status.\");}// If there is no error, update the user data in the store with the updated data.\nconst updatedUser={...store.user,data};setStore({user:updatedUser});// If there is a link, redirect the user.\nif(props===null||props===void 0?void 0:props.link){const[path,hash]=props.link.split(\"#\");const{routeId,pathVariables}=inferInitialRouteFromPath(router.routes,path);if(routeId){router.navigate(routeId,hash,pathVariables);}}}catch(error){console.error(error);isCompleted=false;}};// Set the variant based on the completed state\nconst variant=isCompleted?props===null||props===void 0?void 0:props.variant:null;// Render the original component with the modified props and onClick handler.\nreturn /*#__PURE__*/_jsx(Component,{...props,variant:variant,onClick:handleClick});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withLoggedOut\":{\"type\":\"reactHoc\",\"name\":\"withLoggedOut\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withActionCompleteLesson\":{\"type\":\"reactHoc\",\"name\":\"withActionCompleteLesson\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSignOut\":{\"type\":\"reactHoc\",\"name\":\"withSignOut\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withActiveLicense\":{\"type\":\"reactHoc\",\"name\":\"withActiveLicense\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withNoActiveLicense\":{\"type\":\"reactHoc\",\"name\":\"withNoActiveLicense\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withVariant\":{\"type\":\"reactHoc\",\"name\":\"withVariant\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAuth\":{\"type\":\"reactHoc\",\"name\":\"withAuth\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLoggedIn\":{\"type\":\"reactHoc\",\"name\":\"withLoggedIn\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withEmail\":{\"type\":\"reactHoc\",\"name\":\"withEmail\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withIsLessonComplete\":{\"type\":\"reactHoc\",\"name\":\"withIsLessonComplete\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withStore\":{\"type\":\"reactHoc\",\"name\":\"withStore\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withVariantActiveLicense\":{\"type\":\"reactHoc\",\"name\":\"withVariantActiveLicense\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFirstName\":{\"type\":\"reactHoc\",\"name\":\"withFirstName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FramerAuth.map"],
  "mappings": "kIAAiR,IAAMA,EAASC,EAAY,CAAC,KAAK,KAAK,gBAAgB,GAAM,SAAS,EAAK,CAAC,EAAS,SAASC,EAASC,EAAU,CAAC,OAAOC,GAAO,CAAC,GAAK,CAACC,EAAMC,CAAQ,EAAEN,EAAS,EAAE,OAAAO,EAAU,IAAI,CAAKF,EAAM,iBAAiBG,EAAK,QAAQ,CAAC,MAAM,EAAK,CAAC,EAAE,KAAK,CAAC,CAAC,KAAAC,EAAK,MAAAC,CAAK,IAAI,CAAC,GAAK,CAAC,KAAAC,CAAI,EAAEF,EAAcH,EAANK,EAAe,CAAC,KAAKA,EAAK,gBAAgB,GAAK,SAAS,EAAI,EAAkB,CAAC,SAAS,EAAI,CAA/B,CAAmC,CAAC,CAAG,EAAE,CAAC,CAAC,EAAsBC,EAAKT,EAAU,CAAC,GAAGC,EAAM,MAAMC,CAAK,CAAC,CAAE,CAAE,CAA0+C,SAASQ,EAAoBC,EAAU,CAAC,OAAOC,GAAO,CAAC,IAAIC,EAAY,GAAK,CAACC,CAAK,EAAEC,EAAS,EAAoJ,QAA1HF,EAAYC,EAAM,QAAQ,MAAMD,IAAc,OAAO,OAAOA,EAAY,SAAS,KAAKG,GAASA,EAAQ,SAAS,QAAQ,GAA6B,KAAyBC,EAAKN,EAAU,CAAC,GAAGC,CAAK,CAAC,CAAE,CAAE",
  "names": ["useStore", "createStore", "withAuth", "Component", "props", "store", "setStore", "ue", "B", "data", "error", "user", "p", "withNoActiveLicense", "Component", "props", "_store_user", "store", "useStore", "license", "p"]
}
