{
  "version": 3,
  "sources": ["ssg:https://framer.com/m/framer/store.js@^1.0.0", "ssg:https://framerusercontent.com/modules/5hnoukSEnj86PqSM8hhp/iId7RZ9jnYYPQHyrizIW/TableOfContent.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", "import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{createElement as _createElement}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{useEffect,useState,useLayoutEffect}from\"react\";// Made with love by Cl\u00E9ment. https://lionneclement.com/\n// Full tutorial: https://lionneclement.com/tutorial/how-to-create-table-of-contents-cms-collections-framer\n//UPDATE:\n//This is a modified version in collaboration with Tay Rush. https://twitter.com/taylorrushmore\n// https://www.youtube.com/@taylorrushmore/\nconst HEADING_TO_DISPLAY=[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"];const SCROLL_MARGIN_TOP=80;const useStore=createStore({headings:[]});export function withTableOfContent(Component){return props=>{const[store]=useStore();const[activeSection,setActiveSection]=useState(\"\");const scrollToId=id=>{const element=document.getElementById(id);if(element){element.scrollIntoView({behavior:\"smooth\"});}};useEffect(()=>{const handleScroll=()=>{const sections=store.headings.map(heading=>document.getElementById(heading.id)).filter(Boolean)// Filter out null elements\n;if(sections.length===0)return;const scrollPosition=window.scrollY+SCROLL_MARGIN_TOP;// Find the current active section\nlet currentActiveSection=\"\";for(let i=sections.length-1;i>=0;i--){if(sections[i]&&sections[i].offsetTop<=scrollPosition){currentActiveSection=store.headings[i].id;break;}}// Set first section as active if we're at the top\nif(scrollPosition<SCROLL_MARGIN_TOP&&sections[0]){currentActiveSection=store.headings[0].id;}setActiveSection(currentActiveSection);};// Initial check\nhandleScroll();window.addEventListener(\"scroll\",handleScroll);return()=>{window.removeEventListener(\"scroll\",handleScroll);};},[store.headings]);// If no headings are found, show placeholder\nif(store.headings.length===0||typeof window===\"undefined\"){return /*#__PURE__*/_jsx(Component,{...props});}// Filter and sort headings\nconst filteredHeadings=store.headings.sort((a,b)=>a.originalIndex-b.originalIndex).filter(({type})=>HEADING_TO_DISPLAY.includes(type));// If no headings match the filter, show placeholder\nif(filteredHeadings.length===0){return /*#__PURE__*/_jsx(Component,{...props,title:\"No headings found\"});}// Render the table of contents items\nreturn /*#__PURE__*/_jsx(_Fragment,{children:filteredHeadings.map(({id,heading,type},index)=>/*#__PURE__*/_createElement(Component,{...props,key:`${id}-${index}`,variant:activeSection===id?`${type}-active`:type,title:heading,text:heading,label:heading,children:heading,onClick:()=>scrollToId(id)}))});};}export function withContent(Component){return props=>{const[store,setStore]=useStore();const[newProps,setNewProps]=useState(props);useLayoutEffect(()=>{// Early return if no children\nif(!props?.children?.props?.children){setNewProps(props);return;}const formatHeadings=()=>{const children=props.children.props.children;// Handle both array and single child\nconst childrenArray=Array.isArray(children)?children:[children];const newChildren=childrenArray.map((item,index)=>{// Check if item exists and has the expected structure\nif(!item||!item.type)return item;if([\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"].includes(item.type)){const{formattedId}=formatHeading(item.props?.children,index);// Create a new object for the modified item\nreturn{...item,props:{...item.props,id:formattedId}};}return item;});// Return a new props object with the modified children\nreturn{...props,children:{...props.children,props:{...props.children.props,children:newChildren}}};};const formattedProps=formatHeadings();setNewProps(formattedProps);// Update store with headings\nconst headings=formatTableOfContent(formattedProps.children.props.children);setStore({headings});},[props,setStore]);return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:`.framer-text {\n                    scroll-margin-top: ${SCROLL_MARGIN_TOP}px;\n                }`}),/*#__PURE__*/_jsx(Component,{...newProps})]});};}const formatTableOfContent=children=>{const result=[];// Handle both array and single child\nconst childrenArray=Array.isArray(children)?children:[children];childrenArray.forEach((item,index)=>{// Check if item exists and has the expected structure\nif(!item||!item.type)return;if([\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"].includes(item.type)){const{formattedId,formattedHeading}=formatHeading(item.props?.children,index);result.push({id:formattedId,heading:formattedHeading,type:item.type,originalIndex:index});}});return result;};const formatHeading=(children,index)=>{let formattedHeading=\"\";let formattedId=\"\";if(!children){formattedHeading=`heading-${index}`;}else if(typeof children===\"string\"){formattedHeading=children;}else if(Array.isArray(children)){formattedHeading=children.map(item=>{if(!item)return\"\";if(typeof item===\"string\")return item.trim();if(item.type===\"br\")return\"\";if(item.props?.children){if(typeof item.props.children===\"string\"){return item.props.children.trim();}// Recursively handle nested children\nreturn formatHeading(item.props.children,index).formattedHeading;}return\"\";}).filter(Boolean).join(\" \");}else if(typeof children===\"object\"&&children.props?.children){// Handle React elements\nconst{formattedHeading:nested}=formatHeading(children.props.children,index);formattedHeading=nested;}else{formattedHeading=`heading-${index}`;}// Generate ID from heading text\nformattedId=formattedHeading.trim().toLowerCase().replace(/[^a-z0-9]+/g,\"-\").replace(/^-+|-+$/g,\"\");// Ensure we have a valid ID\nif(!formattedId){formattedId=`heading-${index}`;}return{formattedId,formattedHeading};};\nexport const __FramerMetadata__ = {\"exports\":{\"withTableOfContent\":{\"type\":\"reactHoc\",\"name\":\"withTableOfContent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withContent\":{\"type\":\"reactHoc\",\"name\":\"withContent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TableOfContent.map"],
  "mappings": "4KAAqF,SAASA,EAAYC,EAAO,CACjH,IAAMC,EAAUC,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAGF,CAAM,CAAC,CAAC,CAAC,EACjDG,EAAaC,GAAU,CAC1B,OAAOA,GAAW,aAAYA,EAASA,EAASH,EAAU,KAAK,GAAGA,EAAU,MAAM,OAAO,OAAO,CAAC,GAAGA,EAAU,MAAM,GAAGG,CAAQ,CAAC,CAAE,EACjIC,EAAW,OAAOL,GAAS,SAAS,OAAO,OAAO,CAAC,GAAGA,CAAM,CAAC,EAAEA,EAC7DM,EAAa,IAAI,IACjBC,EAAcH,GAAU,CAC3B,OAAOA,GAAW,aAAYA,EAASA,EAASC,CAAU,GAAGA,EAAW,OAAOD,GAAW,SAAS,OAAO,OAAO,CAAC,GAAGC,EAAW,GAAGD,CAAQ,CAAC,EAAEA,EACjJE,EAAa,QAAQE,GAAQA,EAAOH,CAAU,CAAC,CAAE,EACjD,SAASI,GAAU,CACnB,GAAK,CAACC,EAAMC,CAAQ,EAAEC,EAASP,CAAU,EAIzC,OAFAQ,EAAU,KACVP,EAAa,IA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EAAUS,EAAiB,WAAWjB,CAAK,WAAY,OAAOQ,GAAW,SAAUS,EAAiBT,UAAkB,MAAM,QAAQA,CAAQ,EAAGS,EAAiBT,EAAS,IAAIE,GAAWA,EAAiB,OAAOA,GAAO,SAAgBA,EAAK,KAAK,EAAKA,EAAK,OAAO,KAAW,GAAMA,EAAK,OAAO,SAAa,OAAOA,EAAK,MAAM,UAAW,SAAiBA,EAAK,MAAM,SAAS,KAAK,EACltBE,EAAcF,EAAK,MAAM,SAASV,CAAK,EAAE,iBAAwB,GADie,EAC7d,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,UAAW,OAAOQ,GAAW,UAAUA,EAAS,OAAO,SAAS,CACtK,GAAK,CAAC,iBAAiBU,CAAM,EAAEN,EAAcJ,EAAS,MAAM,SAASR,CAAK,EAAEiB,EAAiBC,CAAO,MAAMD,EAAiB,WAAWjB,CAAK,GAC3I,OAAAW,EAAYM,EAAiB,KAAK,EAAE,YAAY,EAAE,QAAQ,cAAc,GAAG,EAAE,QAAQ,WAAW,EAAE,EAC9FN,IAAaA,EAAY,WAAWX,CAAK,IAAU,CAAC,YAAAW,EAAY,iBAAAM,CAAgB,CAAE",
  "names": ["createStore", "state1", "dataStore", "Data", "setDataStore", "newState", "storeState", "storeSetters", "setStoreState", "setter", "useStore", "state", "setState", "ye", "ue", "useObserveData", "HEADING_TO_DISPLAY", "SCROLL_MARGIN_TOP", "useStore", "createStore", "withTableOfContent", "Component", "props", "store", "activeSection", "setActiveSection", "ye", "scrollToId", "id", "element", "ue", "handleScroll", "sections", "heading", "scrollPosition", "window", "currentActiveSection", "i", "p", "filteredHeadings", "a", "b", "type", "l", "index", "B", "withContent", "setStore", "newProps", "setNewProps", "fe", "formattedProps", "children", "newChildren", "item", "formattedId", "formatHeading", "headings", "formatTableOfContent", "u", "result", "formattedHeading", "nested"]
}
