{"version":3,"file":"AuthStore.2QCe2Qaj.mjs","names":["React.useState","React.useRef","__legacyOverrideHOC_DataObserverContext","_jsx"],"sources":["https:/framerusercontent.com/modules/Dg1LQFroae2DnvOVU7lx/tTpbi5uCBGf1X51k5kfz/AuthStore.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{createStore}from\"https://framer.com/m/framer/store.js\";import*as React from\"react\";const AUTH_KEY=\"DS_IS_LOGGED_IN\";function readAuthStamp(){try{if(typeof window===\"undefined\")return false;return localStorage.getItem(AUTH_KEY)===\"true\";}catch{return false;}}export const useAuthStore=createStore({isLoggedIn:readAuthStamp()});function useAuthState(){const[isLoggedIn,setIsLoggedIn]=React.useState(()=>readAuthStamp());React.useLayoutEffect(()=>{setIsLoggedIn(readAuthStamp());},[]);React.useEffect(()=>{const onCustom=e=>setIsLoggedIn(e.detail.isLoggedIn);const onStorage=e=>{if(e.key===AUTH_KEY)setIsLoggedIn(readAuthStamp());};window.addEventListener(\"authStateChanged\",onCustom);window.addEventListener(\"storage\",onStorage);return()=>{window.removeEventListener(\"authStateChanged\",onCustom);window.removeEventListener(\"storage\",onStorage);};},[]);return isLoggedIn;}// DOM에 직접 display 강제 적용 — Framer 레이아웃 엔진 우회\nfunction useHideRef(shouldHide){const ref=React.useRef(null);React.useLayoutEffect(()=>{const el=ref.current;if(!el)return;if(shouldHide){el.style.setProperty(\"display\",\"none\",\"important\");el.style.setProperty(\"pointer-events\",\"none\",\"important\");}else{el.style.removeProperty(\"display\");el.style.removeProperty(\"pointer-events\");}},[shouldHide]);return ref;}export function trackCurrentPage(){React.useEffect(()=>{const save=()=>{const here=window.location.pathname;if(!here.startsWith(\"/login\")){sessionStorage.setItem(\"redirectAfterLogin\",here);}};save();window.addEventListener(\"popstate\",save);const origPush=history.pushState.bind(history);const origReplace=history.replaceState.bind(history);history.pushState=(...args)=>{origPush(...args);save();};history.replaceState=(...args)=>{origReplace(...args);save();};return()=>{window.removeEventListener(\"popstate\",save);history.pushState=origPush;history.replaceState=origReplace;};},[]);return{};}export function showWhenAuthed(){const isLoggedIn=useAuthState();const ref=useHideRef(!isLoggedIn);return{ref};}export function showWhenGuest(){const isLoggedIn=useAuthState();const ref=useHideRef(isLoggedIn);return{ref};}export function logoutAndGoLogin(){return{onTap(){try{const keysToRemove=[];for(let i=0;i<localStorage.length;i++){const key=localStorage.key(i);if(key&&(key===AUTH_KEY||key===\"DSRCN\"||key.startsWith(\"dls_\")||key.startsWith(\"descope\")||key.startsWith(\"DS_\"))){keysToRemove.push(key);}}keysToRemove.forEach(k=>localStorage.removeItem(k));sessionStorage.clear();}catch{}window.dispatchEvent(new CustomEvent(\"authStateChanged\",{detail:{isLoggedIn:false}}));window.location.replace(\"/login\");}};}export function showAuthedAndLogout(){const isLoggedIn=useAuthState();const ref=useHideRef(!isLoggedIn);return{ref,onTap(){try{localStorage.removeItem(AUTH_KEY);sessionStorage.removeItem(\"redirectAfterLogin\");}catch{}window.dispatchEvent(new CustomEvent(\"authStateChanged\",{detail:{isLoggedIn:false}}));window.location.reload();}};}export function requireAuth(){const isLoggedIn=useAuthState();const[mounted,setMounted]=React.useState(false);React.useEffect(()=>{setMounted(true);},[]);React.useEffect(()=>{if(mounted&&!isLoggedIn){window.location.replace(\"/login\");}},[isLoggedIn,mounted]);return{style:{visibility:!mounted||isLoggedIn?\"visible\":\"hidden\"}};}export function guestLoginButton(){const isLoggedIn=useAuthState();const ref=React.useRef(null);React.useLayoutEffect(()=>{const el=ref.current;if(!el)return;if(isLoggedIn){el.style.setProperty(\"display\",\"none\",\"important\");el.style.setProperty(\"pointer-events\",\"none\",\"important\");}else{el.style.removeProperty(\"display\");el.style.removeProperty(\"pointer-events\");}},[isLoggedIn]);return{ref,onTap(){try{sessionStorage.setItem(\"redirectAfterLogin\",window.location.pathname);}catch{}window.location.replace(\"/login\");}};}export function navigateToMypage(){return{onTap(){window.location.replace(\"/login/mypage\");}};}import{useContext as __legacyOverrideHOC_useContext}from\"react\";import{DataObserverContext as __legacyOverrideHOC_DataObserverContext}from\"framer\";export function withtrackCurrentPage(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...trackCurrentPage(props)});};}withtrackCurrentPage.displayName=\"trackCurrentPage\";export function withshowWhenAuthed(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...showWhenAuthed(props)});};}withshowWhenAuthed.displayName=\"showWhenAuthed\";export function withshowWhenGuest(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...showWhenGuest(props)});};}withshowWhenGuest.displayName=\"showWhenGuest\";export function withlogoutAndGoLogin(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...logoutAndGoLogin(props)});};}withlogoutAndGoLogin.displayName=\"logoutAndGoLogin\";export function withshowAuthedAndLogout(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...showAuthedAndLogout(props)});};}withshowAuthedAndLogout.displayName=\"showAuthedAndLogout\";export function withrequireAuth(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...requireAuth(props)});};}withrequireAuth.displayName=\"requireAuth\";export function withguestLoginButton(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...guestLoginButton(props)});};}withguestLoginButton.displayName=\"guestLoginButton\";export function withnavigateToMypage(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...navigateToMypage(props)});};}withnavigateToMypage.displayName=\"navigateToMypage\";\nexport const __FramerMetadata__ = {\"exports\":{\"navigateToMypage\":{\"type\":\"override\",\"name\":\"navigateToMypage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useAuthStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withnavigateToMypage\":{\"type\":\"reactHoc\",\"name\":\"withnavigateToMypage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"logoutAndGoLogin\":{\"type\":\"override\",\"name\":\"logoutAndGoLogin\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withshowAuthedAndLogout\":{\"type\":\"reactHoc\",\"name\":\"withshowAuthedAndLogout\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWhenGuest\":{\"type\":\"override\",\"name\":\"showWhenGuest\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withlogoutAndGoLogin\":{\"type\":\"reactHoc\",\"name\":\"withlogoutAndGoLogin\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withshowWhenAuthed\":{\"type\":\"reactHoc\",\"name\":\"withshowWhenAuthed\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWhenAuthed\":{\"type\":\"override\",\"name\":\"showWhenAuthed\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withshowWhenGuest\":{\"type\":\"reactHoc\",\"name\":\"withshowWhenGuest\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"trackCurrentPage\":{\"type\":\"override\",\"name\":\"trackCurrentPage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withrequireAuth\":{\"type\":\"reactHoc\",\"name\":\"withrequireAuth\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withguestLoginButton\":{\"type\":\"reactHoc\",\"name\":\"withguestLoginButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"requireAuth\":{\"type\":\"override\",\"name\":\"requireAuth\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withtrackCurrentPage\":{\"type\":\"reactHoc\",\"name\":\"withtrackCurrentPage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showAuthedAndLogout\":{\"type\":\"override\",\"name\":\"showAuthedAndLogout\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"guestLoginButton\":{\"type\":\"override\",\"name\":\"guestL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