{"version":3,"file":"TableOfContents.evkPSpbL.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/ea9cAL08g6NZB8CKaX5d/msTeqigZPdUdcYJDgrvy/TableOfContents.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{startTransition,useState,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";export default function TableOfContents(props){const[headings,setHeadings]=useState([]);useEffect(()=>{// This function looks for your CMS content\nconst findContent=()=>{// Priority 1: The ID 'cms-content'\n// Priority 2: Any div that looks like a CMS collection\nif(typeof document===\"undefined\")return;const contentArea=document.getElementById(\"cms-content\")||document.querySelector(\"[data-framer-component-type='CMSContent']\")||document.querySelector(\".framer-cms-content\");if(contentArea){//Use below to include h2 and h3 in the table of contents, remove double slash to uncomment\nconst found=Array.from(contentArea.querySelectorAll(\"h2,h3\"));const filtered=found.filter(heading=>{if(heading.tagName===\"H2\")return props.showH2;if(heading.tagName===\"H3\")return props.showH3;return false;});//Use below to only include h2 and NOT h3 in the table of contents\n//const found = Array.from(contentArea.querySelectorAll(\"h2\"))\nconst data=filtered.map((h,i)=>{if(!h.id)h.id=`section-${i}`;return{id:h.id,text:h.textContent??\"\",level:h.tagName};});startTransition(()=>setHeadings(data));}};// Run once, then wait a split second for Framer to load the CMS data\nfindContent();const timer=setTimeout(findContent,500);return()=>clearTimeout(timer);},[props.showH2,props.showH3]);const style={display:\"flex\",flexDirection:\"column\",gap:\"12px\",padding:\"10px\",color:props.textColor,fontFamily:\"sans-serif\"};if(headings.length===0){return /*#__PURE__*/_jsx(\"div\",{style:style});}return /*#__PURE__*/_jsx(\"nav\",{style:style,children:headings.map(h=>/*#__PURE__*/_jsx(\"a\",{onClick:e=>{if(typeof document===\"undefined\"||typeof window===\"undefined\"){return;}e.preventDefault();const element=document.getElementById(h.id);if(element){const offset=110// Your header height + some breathing room\n    ;const bodyRect=document.body.getBoundingClientRect().top;const elementRect=element.getBoundingClientRect().top;const elementPosition=elementRect-bodyRect;const offsetPosition=elementPosition-offset;window.scrollTo({top:offsetPosition,behavior:\"smooth\"});}},href:`#${h.id}`,style:{marginLeft:h.level===\"H3\"?\"15px\":\"0px\",textDecoration:\"none\",color:\"inherit\",fontSize:h.level===\"H3\"?\"12px\":\"14px\",fontWeight:h.level===\"H2\"?600:\"normal\",opacity:.8},children:h.text},h.id))});}addPropertyControls(TableOfContents,{textColor:{type:ControlType.Color,defaultValue:\"#333\"},showH2:{type:ControlType.Boolean,title:\"Show H2 headings\",defaultValue:true},showH3:{type:ControlType.Boolean,title:\"Show H3 headings\",defaultValue:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TableOfContents\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TableOfContents.map"],"mappings":"uMAAqJ,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,EAAS,GAAaA,EAAS,CAAC,CAAC,EAAE,MAAc,CAC3P,IAAM,MAAgB,CAEtB,GAAG,OAAO,SAAW,IAAY,OAAO,IAAM,EAAY,SAAS,eAAe,aAAa,GAAG,SAAS,cAAc,2CAA2C,GAAG,SAAS,cAAc,qBAAqB,EAAE,GAAG,EAAY,CAGpO,IAAM,EAFM,MAAM,KAAK,EAAY,iBAAiB,OAAO,CAAsB,CAAC,CAAC,OAAO,GAAa,EAAQ,UAAU,KAAY,EAAM,OAAU,EAAQ,UAAU,MAAY,EAAM,MAEvK,CAAC,CAAC,KAAK,EAAE,KAAK,AAAS,EAAE,KAAG,WAAW,IAAU,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,aAAa,GAAG,MAAM,EAAE,OAAO,EAAG,EAAE,MAAoB,EAAY,CAAI,CAAC,CAAE,CAAC,EAC/J,EAAY,EAAE,IAAM,EAAM,WAAW,EAAY,GAAG,EAAE,UAAU,aAAa,CAAK,CAAE,EAAE,CAAC,EAAM,OAAO,EAAM,MAAM,C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