{"version":3,"file":"TableOfContent.B7SsInPR.mjs","names":["useState","_Fragment","useState"],"sources":["https:/framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js","https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/1XxWQwY0hfK0NPkccp4R/KJkJpnADqLZBYSaIILnx/Utils.js","https:/framer.com/m/Utils-WIyM.js","https:/framerusercontent.com/modules/YHxvsQMrPHvDVwb80Foi/aJ9qPD4VnvG8CTtzejBs/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","/*\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","export const HEADINGS=[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"];const formatHeading=(children,index)=>{let formattedHeading=\"\";let formattedId=\"\";if(typeof children===\"string\"){formattedHeading=children;}else if(Array.isArray(children)){formattedHeading=children.map(item=>{var _item_props;if(typeof item===\"string\")return item.trim();if(typeof((_item_props=item.props)===null||_item_props===void 0?void 0:_item_props.children)===\"string\")return item.props.children.trim();}).join(\" \");}else if(typeof children===\"object\"){if(typeof children.props.children===\"string\"){formattedHeading=children.props.children;}else{formattedHeading=children.type;}}else{formattedHeading=index.toString();}formattedId=formattedHeading.toLowerCase().replace(/[^a-z0-9]+/g,\"-\").replace(/^-+|-+$/g,\"\").trim();return{formattedId,formattedHeading};};export const formatTableOfContent=children=>{const result=[];children.length>0&&children.filter(({type})=>HEADINGS.includes(type)).map((item,index)=>{const children=item.props.children;const{formattedId,formattedHeading}=formatHeading(children,index);result.push({id:formattedId,heading:formattedHeading,type:item.type,originalIndex:index});});return result;};export const formatHeadings=props=>{const newChildren=[];props.children.props.children.forEach((item,index)=>{const children=item.props.children;if(HEADINGS.includes(item.type)){const{formattedId}=formatHeading(children,index);// Create a new object for the modified item\nconst newItem={...item,props:{...item.props,id:formattedId}};newChildren.push(newItem);}else{newChildren.push(item);}});// Return a new props object with the modified children\nreturn{...props,children:{...props.children,props:{...props.children.props,children:newChildren}}};};\nexport const __FramerMetadata__ = {\"exports\":{\"formatTableOfContent\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"HEADINGS\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"formatHeadings\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Utils.map","/*\n * Utils\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/1XxWQwY0hfK0NPkccp4R/KJkJpnADqLZBYSaIILnx/Utils.js\"\n","import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{useEffect,useState}from\"react\";import{formatHeadings,formatTableOfContent}from\"https://framer.com/m/Utils-WIyM.js\";// Made with love by Clément: https://lionneclement.com/\n// Full tutorial: https://framermart.com/tutorial/how-to-create-table-of-contents-cms-collections-framer\nconst HEADING_TO_DISPLAY=[\"h2\"];const SCROLL_MARGIN_TOP=80;const useStore=createStore({headings:[]});export function withTableOfContent(Component){return props=>{const[store]=useStore();return /*#__PURE__*/_jsx(_Fragment,{children:store.headings.length>0&&window?store.headings.sort((a,b)=>a.originalIndex-b.originalIndex).filter(({type})=>HEADING_TO_DISPLAY.includes(type)).map(({id,heading,type})=>/*#__PURE__*/_jsx(\"div\",{style:{marginBottom:\"6px\"},children:/*#__PURE__*/_jsx(Component,{...props,variant:type,title:heading,link:`${window.location.pathname}#${id}`})},id)):/*#__PURE__*/_jsx(Component,{...props})});};}export function withContent(Component){return props=>{const[store,setStore]=useStore();const[newProps,setNewProps]=useState(props);useEffect(()=>{setStore({headings:formatTableOfContent(newProps.children.props.children)});},[newProps]);useEffect(()=>{setNewProps(formatHeadings(props));},[props]);return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:`.framer-text {\n                    scroll-margin-top: ${SCROLL_MARGIN_TOP}px;\n                }`}),/*#__PURE__*/_jsx(Component,{...newProps})]});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withContent\":{\"type\":\"reactHoc\",\"name\":\"withContent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withTableOfContent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