{"version":3,"file":"TableOfContent.CQw9Uno7.mjs","names":["useState","_Fragment","useState","__esmMin","init_npm_react_18_3_1","window","_e","init_jsx_runtime","c","p","ce","init_ssg_sandbox_shims","init_framer_BpuvUAiZ","useObserveData","Data","createStore","dataStore","state1","setDataStore","newState","storeState","storeSetters","setStoreState","setter","useStore","state","setState","init_createStore","init_store_js__1_0","HEADINGS","formatHeading","formatTableOfContent","formatHeadings","init_Utils","formattedHeading","formattedId","children","item","index","result","type","newChildren","props","newItem","withTableOfContent","store","setStore","pathname","headings","l","aEl","a","bEl","b","HEADING_TO_DISPLAY","isActive","id","Component","heading","withContent","newProps","setNewProps","formatted","existing","prev","filtered","h","f","headingElements","observer","visible","entries","entry","SCROLL_MARGIN_TOP","el","init_TableOfContent"],"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:/framerusercontent.com/modules/vvnzAzT8Dp0XMvVtrvXV/udqI2vzICSsmEhVadx4E/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","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\";const HEADING_TO_DISPLAY=[\"h2\"];const SCROLL_MARGIN_TOP=160;const useStore=createStore({headings:[],activeId:null});export function withTableOfContent(Component){return props=>{const[store,setStore]=useStore();const pathname=window.location.pathname;const headings=store.allHeadings?.[pathname]||[];useEffect(()=>{setStore({allHeadings:{[pathname]:store.allHeadings?.[pathname]||[]}});},[pathname]);return /*#__PURE__*/_jsx(_Fragment,{children:headings.length>0&&window?headings.sort((a,b)=>{const aEl=document.getElementById(a.id);const bEl=document.getElementById(b.id);if(!aEl||!bEl)return 0;return aEl.getBoundingClientRect().top-bEl.getBoundingClientRect().top;}).filter(({type})=>HEADING_TO_DISPLAY.includes(type)).map(({id,heading,type})=>{const isActive=id===store.activeId;return /*#__PURE__*/_jsx(Component,{...props,variant:isActive?`${type}-active`:type,title:heading,link:`${window.location.pathname}#${id}`});}):/*#__PURE__*/_jsx(Component,{...props})});};}export function withContent(Component){return props=>{const[store,setStore]=useStore();const[newProps,setNewProps]=useState(props);// Format headings with IDs\nuseEffect(()=>{setNewProps(formatHeadings(props));},[props]);// Extract headings for TOC\nuseEffect(()=>{const formatted=formatTableOfContent(newProps.children?.props?.children);if(!formatted||formatted.length===0)return;const pathname=window.location.pathname;setStore(prev=>{const existing=prev.allHeadings?.[pathname]||[];const filtered=formatted.filter(f=>!existing.some(h=>h.id===f.id));if(filtered.length===0)return{};return{allHeadings:{...prev.allHeadings,[pathname]:[...existing,...filtered]}};});},[newProps]);// Track which heading is in view\nuseEffect(()=>{const headingElements=Array.from(document.querySelectorAll(\"h2\"));const observer=new IntersectionObserver(entries=>{const visible=entries.filter(entry=>entry.isIntersecting).sort((a,b)=>b.intersectionRatio-a.intersectionRatio);if(visible.length>0){setStore({activeId:visible[0].target.id});}},{rootMargin:`-${SCROLL_MARGIN_TOP}px 0px 0px 0px`,threshold:.1});headingElements.forEach(el=>observer.observe(el));return()=>observer.disconnect();},[]);return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:`\n                    html {\n                        scroll-behavior: smooth;\n                    }\n                    .framer-text {\n                        scroll-margin-top: ${SCROLL_MARGIN_TOP}px;\n                    }\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=./TableOfContent.map"],"mappings":"A,8MAA8E,SAAgBe,EAAY,EAAO,CACjH,IAAMC,EAAUF,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAGG,CAAM,CAAC,CAAC,CAAC,EACjDC,EAAa,GAAU,CAC1B,OAAOC,GAAW,aAAY,EAASA,EAASH,EAAU,KAAK,GAAG,EAAU,MAAM,OAAO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