{"version":3,"file":"TableOfContents.B_XlTht8.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/izkketfJTCCUNzzn0aT0/C7pK0dmdjyhEFbWNCyRk/TableOfContents.js"],"sourcesContent":["// Table of Contents component for blog posts - automatically generates navigation from headings\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Table of Contents\n *\n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 400\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function TableOfContents(props){const{contentLayer,title,backgroundColor,textColor,activeColor,borderRadius,padding,showBorder,borderColor,titleFont,itemFont,indentSize}=props;const[activeId,setActiveId]=useState(\"\");const[tocItems,setTocItems]=useState([]);// Scan for headings in the rendered content\nuseEffect(()=>{if(typeof window===\"undefined\")return;const scanHeadings=()=>{// Find the TOC component first\nconst tocComponent=document.querySelector(\"[data-toc-component]\");if(!tocComponent)return;// Find the contentLayer within the TOC component\n// It should be a direct child or nearby sibling that was passed as contentLayer prop\nlet contentContainer=null;// Try to find a container with data-framer-name=\"Blog Content\" or similar\nconst blogContent=document.querySelector('[data-framer-name=\"Blog Content\"]');if(blogContent){contentContainer=blogContent;}else{// Fallback: look for the Content layer\ncontentContainer=document.querySelector('[data-framer-name=\"Content\"]');}if(!contentContainer)return;const headings=contentContainer.querySelectorAll(\"h1, h2, h3, h4, h5, h6\");const items=[];headings.forEach((heading,index)=>{const level=parseInt(heading.tagName.substring(1));const text=heading.textContent||\"\";const id=heading.id||`heading-${index}`;// Assign ID if not present\nif(!heading.id){heading.id=id;}items.push({id,text,level});});startTransition(()=>setTocItems(items));};// Initial scan\nscanHeadings();// Rescan after a short delay to catch dynamically loaded content\nconst timer=setTimeout(scanHeadings,500);// Set up a MutationObserver to detect content changes\nconst observer=new MutationObserver(scanHeadings);observer.observe(document.body,{childList:true,subtree:true});return()=>{clearTimeout(timer);observer.disconnect();};},[contentLayer]);useEffect(()=>{if(typeof window===\"undefined\"||tocItems.length===0)return;const headingElements=tocItems.map(item=>document.getElementById(item.id)).filter(Boolean);const observer=new IntersectionObserver(entries=>{entries.forEach(entry=>{if(entry.isIntersecting){startTransition(()=>setActiveId(entry.target.id));}});},{rootMargin:\"-20% 0px -80% 0px\"});headingElements.forEach(heading=>{if(heading)observer.observe(heading);});return()=>observer.disconnect();},[tocItems]);const handleClick=id=>{if(typeof window===\"undefined\")return;const element=document.getElementById(id);if(element){element.scrollIntoView({behavior:\"smooth\",block:\"start\"});}};const minLevel=tocItems.length>0?Math.min(...tocItems.map(item=>item.level)):1;return /*#__PURE__*/_jsxs(\"div\",{\"data-toc-component\":true,style:{...props.style,position:\"relative\",backgroundColor,borderRadius,padding,border:showBorder?`1px solid ${borderColor}`:\"none\",overflow:\"auto\"},children:[/*#__PURE__*/_jsx(\"h3\",{style:{margin:0,marginBottom:16,color:textColor,...titleFont},children:title}),/*#__PURE__*/_jsx(\"nav\",{children:/*#__PURE__*/_jsx(\"ul\",{style:{listStyle:\"none\",margin:0,padding:0},children:tocItems.map(item=>/*#__PURE__*/_jsx(\"li\",{style:{marginBottom:8,paddingLeft:(item.level-minLevel)*indentSize},children:/*#__PURE__*/_jsx(\"a\",{href:`#${item.id}`,onClick:e=>{e.preventDefault();handleClick(item.id);},style:{color:activeId===item.id?activeColor:textColor,textDecoration:\"none\",cursor:\"pointer\",display:\"block\",transition:\"color 0.2s ease\",opacity:activeId===item.id?1:.7,fontWeight:activeId===item.id?600:400,...itemFont},onMouseEnter:e=>{e.currentTarget.style.color=activeColor;},onMouseLeave:e=>{e.currentTarget.style.color=activeId===item.id?activeColor:textColor;},children:item.text})},item.id))})})]});}addPropertyControls(TableOfContents,{contentLayer:{type:ControlType.ComponentInstance,title:\"Content Layer\"},title:{type:ControlType.String,title:\"Title\",defaultValue:\"Table of Contents\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#F5F5F5\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},activeColor:{type:ControlType.Color,title:\"Active Color\",defaultValue:\"#0099FF\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:8,min:0,max:32,step:1,unit:\"px\"},padding:{type:ControlType.Number,title:\"Padding\",defaultValue:20,min:0,max:60,step:4,unit:\"px\"},showBorder:{type:ControlType.Boolean,title:\"Border\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},borderColor:{type:ControlType.Color,title:\"Border Color\",defaultValue:\"#EEEEEE\",hidden:({showBorder})=>!showBorder},titleFont:{type:ControlType.Font,title:\"Title Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"22px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}},itemFont:{type:ControlType.Font,title:\"Item Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"15px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"}},indentSize:{type:ControlType.Number,title:\"Indent Size\",defaultValue:16,min:0,max:40,step:4,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TableOfContents\",\"slots\":[\"contentLayer\"],\"annotations\":{\"framerIntrinsicHeight\":\"400\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"300\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TableOfContents.map"],"mappings":"wMASG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,eAAa,QAAM,kBAAgB,YAAU,cAAY,eAAa,UAAQ,aAAW,cAAY,YAAU,WAAS,cAAY,EAAW,CAAC,EAAS,GAAaA,EAAS,EAAE,EAAO,CAAC,EAAS,GAAaA,EAAS,CA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