{"version":3,"file":"AuthGuard.47FePopW.mjs","names":[],"sources":["https:/framerusercontent.com/modules/Kc1CKF1kHXB8LqHOIVGz/Fb3JpvJarIbAdFtyHv9K/AuthGuard.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect}from\"react\";import{useAuth}from\"https://framerusercontent.com/modules/HhRWwZczSNoa74ILHIk6/42trBW99wqW7xBWfUuee/authStore.js\";import{RenderTarget}from\"framer\";import{useCurrentLocation}from\"https://framer.com/m/FramerDevGemsPublic-djHN.js\";// ─── Code Overrides ───────────────────────────────────────────────────────────\n/**\n * Apply to any page/frame that requires the user to be logged in.\n * Redirects to / if no token is found.\n */export function withAuthRequired(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const{isAuthenticated}=useAuth();const isEditor=RenderTarget.current()===RenderTarget.canvas;const[,setCurrentLocation]=useCurrentLocation();useEffect(()=>{if(isEditor)return;if(!isAuthenticated){setCurrentLocation(\"/forbudt\");}},[isAuthenticated]);if(!isAuthenticated)return null;return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}/**\n * Apply to the /login or /register page.\n * Redirects already-authenticated users away to /profil.\n */export function withGuestOnly(Component){return props=>{const{isAuthenticated}=useAuth();const isEditor=RenderTarget.current()===RenderTarget.canvas;const[,setCurrentLocation]=useCurrentLocation();useEffect(()=>{if(isEditor)return;if(isAuthenticated){setCurrentLocation(\"/forbudt\");}},[isAuthenticated]);return /*#__PURE__*/_jsx(Component,{...props});};}/**\n * Injects the current user's name into the component as the `text` prop.\n * Apply to a Text layer to display e.g. \"Hej, Anders\".\n */export function withUserName(Component){return props=>{const{user}=useAuth();return /*#__PURE__*/_jsx(Component,{...props,text:user?.name??\"\"});};}/**\n * Injects the current user's email into the component as the `text` prop.\n */export function withUserEmail(Component){return props=>{const{user}=useAuth();return /*#__PURE__*/_jsx(Component,{...props,text:user?.email??\"\"});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withGuestOnly\":{\"type\":\"reactHoc\",\"name\":\"withGuestOnly\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAuthRequired\":{\"type\":\"reactHoc\",\"name\":\"withAuthRequired\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserEmail\":{\"type\":\"reactHoc\",\"name\":\"withUserEmail\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserName\":{\"type\":\"reactHoc\",\"name\":\"withUserName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"6OAIG,SAAgB,EAAiB,EAAU,CAAC,OAAoB,GAAY,EAAM,IAAM,CAAC,GAAK,CAAC,mBAAiB,GAAS,CAAO,EAAS,EAAa,SAAS,GAAG,EAAa,OAAY,EAAE,GAAoB,GAAoB,CAA6I,OAA5I,MAAc,CAAI,GAAoB,GAAiB,EAAmB,WAAW,EAAI,CAAC,EAAgB,CAAC,CAAK,EAAgD,EAAK,EAAU,CAAK,MAAI,GAAG,EAAM,CAAC,CAA3D,MAA8D,kBAJnY,IAAwC,IAAkH,IAAiC,IAAiF"}