{"version":3,"file":"CMS_Protection.7-diofPg.mjs","names":["useState","useState"],"sources":["https:/framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js","https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/rguVIZf2CjgcJrHctZiM/38TPyw85f3I3mkkuxANk/CMS_Protection.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","// Copyright by Shams.digital for free production level uses.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{forwardRef,useState,useEffect}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";// Configuration - Update these values\nconst CONFIG={protectedCollections:[\"work\"],password:\"Design\",sessionKey:\"framer_cms_auth\"};// Create Framer store for authentication state\nconst useAuthStore=createStore({isAuthenticated:false,showModal:false,currentPath:\"\"});// Password Protection Modal Component\nconst PasswordModal=({onSubmit,error})=>{const[password,setPassword]=useState(\"\");return /*#__PURE__*/_jsx(\"div\",{style:{position:\"fixed\",top:0,left:0,right:0,bottom:0,backgroundColor:\"rgba(0, 0, 0, 0.85)\",backdropFilter:\"blur(8px)\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",zIndex:999999,fontFamily:\"-apple-system, BlinkMacSystemFont, sans-serif\"},children:/*#__PURE__*/_jsxs(\"div\",{style:{backgroundColor:\"#ffffff\",borderRadius:\"16px\",padding:\"48px\",maxWidth:\"420px\",width:\"90%\",boxShadow:\"0 25px 50px -12px rgba(0, 0, 0, 0.25)\"},children:[/*#__PURE__*/_jsxs(\"div\",{style:{textAlign:\"center\",marginBottom:\"32px\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{width:\"64px\",height:\"64px\",backgroundColor:\"#f3f4f6\",borderRadius:\"50%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",margin:\"0 auto 16px\",fontSize:\"24px\"},children:\"🔒\"}),/*#__PURE__*/_jsx(\"h2\",{style:{margin:\"0 0 8px 0\",fontSize:\"24px\",fontWeight:\"600\",color:\"#111827\"},children:\"Password Required\"}),/*#__PURE__*/_jsxs(\"p\",{style:{margin:0,fontSize:\"16px\",color:\"#6b7280\"},children:[\"Client work is private — please enter the password or email Tiffany to take a look.\",/*#__PURE__*/_jsx(\"p\",{children:/*#__PURE__*/_jsx(\"a\",{href:\"https://www.tiffanysoohoo.com\",children:\"Back to portfolio\"})})]})]}),/*#__PURE__*/_jsxs(\"form\",{onSubmit:e=>{e.preventDefault();onSubmit(password);},children:[/*#__PURE__*/_jsx(\"input\",{type:\"password\",value:password,onChange:e=>setPassword(e.target.value),placeholder:\"Enter password\",autoFocus:true,style:{width:\"100%\",padding:\"16px\",fontSize:\"16px\",border:error?\"2px solid #ef4444\":\"2px solid #e5e7eb\",borderRadius:\"12px\",marginBottom:\"16px\",outline:\"none\",boxSizing:\"border-box\"}}),error&&/*#__PURE__*/_jsxs(\"div\",{style:{padding:\"12px 16px\",backgroundColor:\"#fef2f2\",border:\"1px solid #fecaca\",borderRadius:\"8px\",marginBottom:\"20px\",fontSize:\"14px\",color:\"#dc2626\",display:\"flex\",alignItems:\"center\",gap:\"8px\"},children:[/*#__PURE__*/_jsx(\"span\",{children:\"⚠️\"}),error]}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",style:{width:\"100%\",padding:\"16px\",fontSize:\"16px\",fontWeight:\"600\",color:\"#ffffff\",backgroundColor:\"#3b82f6\",border:\"none\",borderRadius:\"12px\",cursor:\"pointer\"},children:\"Access Content\"})]})]})});};// Helper function to check if current page is from protected CMS collections\nconst isProtectedCMSPage=()=>{if(typeof window===\"undefined\")return false;const path=window.location.pathname.toLowerCase();const search=window.location.search.toLowerCase();// Remove trailing slash for consistent comparison\nconst cleanPath=path.endsWith(\"/\")&&path.length>1?path.slice(0,-1):path;return CONFIG.protectedCollections.some(collection=>{const slug=collection.toLowerCase();// Check ALL possible CMS URL patterns:\nreturn(// Direct collection access: /cms\ncleanPath===`/${slug}`||// Collection with trailing slash: /cms/\npath===`/${slug}/`||// All collection items: /cms/item1, /cms/item2, /cms/any-content\ncleanPath.startsWith(`/${slug}/`)||// Collection with query parameters: /cms?item=something\ncleanPath===`/${slug}`&&search.length>0||// Collection pagination: /cms-1, /cms-2, etc.\nnew RegExp(`^/${slug}-\\\\d+/?$`).test(cleanPath)||// Any deep nested paths: /cms/category/item\nnew RegExp(`^/${slug}(/.*)?$`).test(cleanPath)||// Query-based CMS access patterns\nsearch.includes(`collection=${slug}`)||search.includes(`cms=${slug}`));});};// Main CMS protection override\nexport function withCMSProtection(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useAuthStore();const[error,setError]=useState(\"\");const[isLoading,setIsLoading]=useState(true);// Check authentication status\nuseEffect(()=>{const checkAuth=()=>{const currentPath=window.location.pathname;if(isProtectedCMSPage()){// This is a protected CMS page, check authentication\nconst stored=sessionStorage.getItem(CONFIG.sessionKey);if(stored===\"authenticated\"){setStore({isAuthenticated:true,showModal:false,currentPath});}else{setStore({isAuthenticated:false,showModal:true,currentPath});}}else{// Not a protected page, allow access\nsetStore({isAuthenticated:true,showModal:false,currentPath});}setIsLoading(false);};// Small delay to ensure DOM and routing are ready\nconst timer=setTimeout(checkAuth,100);return()=>clearTimeout(timer);},[setStore]);// Handle navigation changes\nuseEffect(()=>{const handleNavigationChange=()=>{const currentPath=window.location.pathname;// Re-evaluate protection status on every navigation\nif(isProtectedCMSPage()){const stored=sessionStorage.getItem(CONFIG.sessionKey);if(stored!==\"authenticated\"){setStore({isAuthenticated:false,showModal:true,currentPath});}else{setStore({isAuthenticated:true,showModal:false,currentPath});}}else{setStore({isAuthenticated:true,showModal:false,currentPath});}};// Override browser navigation methods to catch programmatic navigation\nconst originalPushState=window.history.pushState;const originalReplaceState=window.history.replaceState;window.history.pushState=function(...args){originalPushState.apply(window.history,args);setTimeout(handleNavigationChange,50);};window.history.replaceState=function(...args){originalReplaceState.apply(window.history,args);setTimeout(handleNavigationChange,50);};// Listen for browser back/forward navigation\nwindow.addEventListener(\"popstate\",handleNavigationChange);// Listen for hash changes (in case CMS uses hash routing)\nwindow.addEventListener(\"hashchange\",handleNavigationChange);// Check if path has changed since last render\nif(store.currentPath!==window.location.pathname){setTimeout(handleNavigationChange,100);}return()=>{window.history.pushState=originalPushState;window.history.replaceState=originalReplaceState;window.removeEventListener(\"popstate\",handleNavigationChange);window.removeEventListener(\"hashchange\",handleNavigationChange);};},[store.currentPath,setStore]);const handlePasswordSubmit=password=>{if(password===CONFIG.password){setStore({isAuthenticated:true,showModal:false,currentPath:window.location.pathname});setError(\"\");sessionStorage.setItem(CONFIG.sessionKey,\"authenticated\");}else{setError(\"Incorrect password. Please try again.\");// Clear error after 3 seconds\nsetTimeout(()=>setError(\"\"),3e3);}};// Show loading state\nif(isLoading){return /*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",alignItems:\"center\",justifyContent:\"center\",minHeight:\"200px\",opacity:.5},children:\"Loading...\"});}// CRITICAL: Always check if current page is protected\nconst isCurrentPageProtected=isProtectedCMSPage();// Show password modal for protected pages without authentication\nif(isCurrentPageProtected&&(!store.isAuthenticated||store.showModal)){return /*#__PURE__*/_jsx(PasswordModal,{onSubmit:handlePasswordSubmit,error:error});}// Show component only if:\n// 1. Page is not protected, OR\n// 2. Page is protected AND user is authenticated\nif(!isCurrentPageProtected||isCurrentPageProtected&&store.isAuthenticated){return /*#__PURE__*/_jsx(Component,{ref:ref,...props});}// Fallback: show nothing for protected pages without auth\nreturn null;});}\nexport const __FramerMetadata__ = {\"exports\":{\"withCMSProtection\":{\"type\":\"reactHoc\",\"name\":\"withCMSProtection\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMS_Protection.map"],"mappings":"8MAA8E,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,CA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