{"version":3,"file":"TableOfContent.DeeC13Is.mjs","names":["useStore","useState","useState","_Fragment"],"sources":["https:/framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js","https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/e5DQmVALYPlKtNm2spYc/fH6bBIl8fsszspf22Hr9/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","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\";const HEADING_SELECTOR='[data-framer-name=\"Content\"] h2';const SCROLL_MARGIN_TOP=80;const useStore=createStore({headings:[]});function slugify(text){return text.trim().toLowerCase().normalize(\"NFD\").replace(/[\\u0300-\\u036f]/g,\"\").replace(/[^a-z0-9]+/g,\"-\").replace(/^-+|-+$/g,\"\");}export function withTableOfContent(Component){return props=>{const[store]=useStore();const[activeSection,setActiveSection]=useState(-1);const scrollToIndex=index=>{const nodes=document.querySelectorAll(HEADING_SELECTOR);const el=nodes[index];if(el)el.scrollIntoView({behavior:\"smooth\"});};useEffect(()=>{const handleScroll=()=>{const nodes=Array.from(document.querySelectorAll(HEADING_SELECTOR));const scrollPos=window.scrollY-SCROLL_MARGIN_TOP-10;for(let i=nodes.length-1;i>=0;i--){if(nodes[i].offsetTop<=scrollPos){setActiveSection(i);break;}}};window.addEventListener(\"scroll\",handleScroll);return()=>window.removeEventListener(\"scroll\",handleScroll);},[store.headings]);// Render one Component per heading. If empty, render NOTHING (no placeholder).\nif(!store.headings||store.headings.length===0){return null;}return /*#__PURE__*/_jsx(_Fragment,{children:store.headings.map(({heading},i)=>/*#__PURE__*/_jsx(Component,{...props,variant:activeSection===i?\"h2-active\":\"h2\",title:heading,onClick:()=>scrollToIndex(i)},i))});};}export function withContent(Component){return props=>{const[,setStore]=useStore();useEffect(()=>{const scan=()=>{const nodes=document.querySelectorAll(HEADING_SELECTOR);const headings=[];nodes.forEach(node=>{const text=(node.textContent||\"\").trim();if(text)headings.push({heading:text});});// Debug: see what we find in the browser console\nconsole.log(\"[TOC scan] headings:\",headings);setStore({headings});};// Scan now, then again as content hydrates, plus on any DOM change\nscan();const t1=setTimeout(scan,250);const t2=setTimeout(scan,1e3);const observer=new MutationObserver(()=>scan());observer.observe(document.body,{childList:true,subtree:true});return()=>{clearTimeout(t1);clearTimeout(t2);observer.disconnect();};},[]);return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:`[data-framer-name=\"h2\"] { scroll-margin-top: ${SCROLL_MARGIN_TOP}px; }`}),/*#__PURE__*/_jsx(Component,{...props})]});};}\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":"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,CAAC,CAAC,EAC7D,EAAa,IAAI,IACjB,EAAc,GAAU,CAC3B,OAAO,GAAW,aAAY,EAAS,EAAS,EAAW,EAAE,EAAW,OAAO,GAAW,SAAS,OAAO,OAAO,CAAC,GAAG,EAAW,GAAG,EAAS,CAAC,CAAC,EACjJ,EAAa,QAAQ,GAAQ,EAAO,EAAW,CAAC,EAChD,SAASA,GAAU,CACnB,GAAK,CAAC,EAAM,GAAUC,EAAS,EAAW,CAK1C,OAHA,OACA,EAAa,IAAI,EAAS,KAAW,EAAa,OAAO,EAAS,EAAG,EAAE,CAAC,CACrE,GAAgB,GAAG,IAAM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