{"version":3,"file":"TableofContents.CVXlBkwj.mjs","names":["useState","useMemo","_Fragment","useState","useRef"],"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/73nJ1qD9Y5hdi48cp30G/TTnVmfZZleQxK4UPP8uJ/TableofContents.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,useMemo,useRef,useState}from\"react\";import{formatHeadings,formatTableOfContent}from\"https://framer.com/m/Utils-WIyM.js\";const HEADING_TO_DISPLAY=[\"h2\",\"h3\",\"h4\"];const SCROLL_MARGIN_TOP=160;const useStore=createStore({headings:[],activeId:null,activeParentId:null});export function withTableOfContent(Component){return props=>{const[store]=useStore();const ordered=useMemo(()=>store.headings.slice().sort((a,b)=>a.originalIndex-b.originalIndex).filter(({type})=>HEADING_TO_DISPLAY.includes(type)),[store.headings]);if(!(ordered.length>0&&typeof window!==\"undefined\")){return /*#__PURE__*/_jsx(Component,{...props});}return /*#__PURE__*/_jsx(_Fragment,{children:ordered.map(({id,heading,type})=>{const isActive=store.activeId===id||store.activeParentId===id;const variant=isActive?`${type}-active`:type;return /*#__PURE__*/_jsx(Component,{...props,variant:variant,title:heading,link:`${window.location.pathname}#${id}`},id);})});};}export function withContent(Component){return props=>{const[store,setStore]=useStore();const[newProps,setNewProps]=useState(props);const positionsRef=useRef([]);const ordered=useMemo(()=>store.headings.slice().sort((a,b)=>a.originalIndex-b.originalIndex).filter(({type})=>HEADING_TO_DISPLAY.includes(type)),[store.headings]);useEffect(()=>{setStore({headings:formatTableOfContent(newProps.children?.props?.children)});},[newProps,setStore]);useEffect(()=>{setNewProps(formatHeadings(props));},[props]);// scroll spy\nuseEffect(()=>{if(typeof window===\"undefined\")return;let rAfId=0;const recalcPositions=()=>{positionsRef.current=ordered.map(({id})=>{const el=document.getElementById(id);if(!el)return Number.POSITIVE_INFINITY;const rect=el.getBoundingClientRect();return rect.top+window.scrollY;});};const updateActive=()=>{const y=window.scrollY+SCROLL_MARGIN_TOP+1;let activeIdx=0;const pos=positionsRef.current;for(let i=0;i<pos.length;i++){if(pos[i]<=y)activeIdx=i;else break;}const active=ordered[activeIdx];if(active){// Find nearest parent h2 above this heading\nlet parentId=null;if(active.type!==\"h2\"){for(let i=activeIdx;i>=0;i--){if(ordered[i].type===\"h2\"){parentId=ordered[i].id;break;}}}if(active.id!==store.activeId||parentId!==store.activeParentId){setStore({activeId:active.id,activeParentId:parentId});}}};const onScroll=()=>{if(rAfId)return;rAfId=window.requestAnimationFrame(()=>{rAfId=0;updateActive();});};const onResize=()=>{recalcPositions();updateActive();};recalcPositions();updateActive();window.addEventListener(\"scroll\",onScroll,{passive:true});window.addEventListener(\"resize\",onResize);return()=>{window.removeEventListener(\"scroll\",onScroll);window.removeEventListener(\"resize\",onResize);if(rAfId)cancelAnimationFrame(rAfId);};},[ordered,setStore,store.activeId,store.activeParentId]);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\":{\"type\":\"reactHoc\",\"name\":\"withTableOfContent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TableofContents.map"],"mappings":"4NAA8E,SAAgB,EAAY,EAAO,CACjH,IAAM,EAAU,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAG,CAAM,CAAC,CAAC,CAAC,EACjD,EAAa,GAAU,CAC1B,OAAO,GAAW,aAAY,EAAS,EAAS,EAAU,KAAK,GAAG,EAAU,M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