{"version":3,"file":"TOC.Cs50XTUG.mjs","names":["useRef","useState","useCallback"],"sources":["https:/framerusercontent.com/modules/6f3acmgABW8Q7GvF1xwU/uYDWZVNLEaTVsrMHNJ4x/TOC.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useCallback,useEffect,useLayoutEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";function slugify(text){return text.trim().toLowerCase().replace(/\\s+/g,\"-\").replace(/[^a-z0-9-]/g,\"\").replace(/-+/g,\"-\").replace(/^-|-$/g,\"\")||\"section\";}function ensureUniqueId(id,existing){let out=id;let n=0;while(existing.has(out)){n+=1;out=`${id}-${n}`;}existing.add(out);return out;}function findScanRoot(node,exclude){let el=node.parentElement;while(el&&el!==document.body){const headings=el.querySelectorAll(\"h2, h3\");for(const h of headings){if(!exclude.contains(h))return el;}el=el.parentElement;}return document.body;}/**\n * Table of Contents – finds h2/h3 in sibling content (same parent Frame) and builds jump links.\n * Place TOC and your text block as siblings in one Frame; headings in the text are picked up automatically.\n *\n * @framerIntrinsicWidth 280\n * @framerIntrinsicHeight 200\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function TableOfContents(props){const{itemFont,linkColor=\"#333\",linkHoverColor=\"#000\",activeColor=\"#0066cc\",backgroundColor=\"transparent\",padding=16,gap=8,indentH3=16,borderRadius=8,style}=props;const rootRef=useRef(null);const scanRootRef=useRef(null);const[items,setItems]=useState([]);const scanHeadings=useCallback(()=>{if(typeof document===\"undefined\"||!rootRef.current)return;const tocRoot=rootRef.current;const scanRoot=scanRootRef.current;if(!scanRoot)return;const allHeadings=scanRoot.querySelectorAll(\"h2, h3\");const existingIds=new Set;const next=[];allHeadings.forEach(el=>{if(tocRoot.contains(el))return;const level=el.tagName===\"H2\"?2:3;const label=(el.textContent||\"\").trim()||\"Section\";const id=el.id&&/^[a-z0-9-]+$/i.test(el.id)?el.id:ensureUniqueId(slugify(label),existingIds);if(!el.id)el.id=id;next.push({id,label,level});});startTransition(()=>setItems(next));},[]);useLayoutEffect(()=>{if(!rootRef.current)return;scanRootRef.current=findScanRoot(rootRef.current,rootRef.current);scanHeadings();},[scanHeadings]);useEffect(()=>{const timer=setTimeout(()=>{if(rootRef.current){scanRootRef.current=findScanRoot(rootRef.current,rootRef.current);}scanHeadings();},300);return()=>clearTimeout(timer);},[scanHeadings]);useEffect(()=>{if(typeof document===\"undefined\")return;const scanRoot=scanRootRef.current;if(!scanRoot)return;const observer=new MutationObserver(()=>{if(rootRef.current){scanRootRef.current=findScanRoot(rootRef.current,rootRef.current);}scanHeadings();});observer.observe(scanRoot,{childList:true,subtree:true,characterData:true});return()=>observer.disconnect();},[scanHeadings]);const scrollToSection=useCallback((e,id)=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;e.preventDefault();const el=document.getElementById(id);if(el){const top=el.getBoundingClientRect().top+window.scrollY-32;window.scrollTo({top,behavior:\"smooth\"});}},[]);return /*#__PURE__*/_jsx(\"div\",{ref:rootRef,style:{...style,position:\"relative\"},children:/*#__PURE__*/_jsx(\"nav\",{style:{background:backgroundColor,borderRadius,padding,display:\"flex\",flexDirection:\"column\",gap},\"aria-label\":\"Table of contents\",children:/*#__PURE__*/_jsx(\"ul\",{style:{listStyle:\"none\",margin:0,padding:\"64px 0 0 0\",display:\"flex\",flexDirection:\"column\",gap},children:items.map(item=>/*#__PURE__*/_jsx(\"li\",{style:{margin:0,paddingLeft:item.level===3?indentH3:0},children:/*#__PURE__*/_jsx(\"a\",{href:`#${item.id}`,onClick:e=>scrollToSection(e,item.id),style:{...itemFont,color:linkColor,textDecoration:\"none\",cursor:\"pointer\",display:\"block\"},onMouseEnter:e=>{e.currentTarget.style.color=linkHoverColor;},onMouseLeave:e=>{e.currentTarget.style.color=linkColor;},children:item.label})},item.id))})})});}addPropertyControls(TableOfContents,{itemFont:{type:ControlType.Font,title:\"Link font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"14px\",variant:\"Regular\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"}},linkColor:{type:ControlType.Color,title:\"Link color\",defaultValue:\"#333333\"},linkHoverColor:{type:ControlType.Color,title:\"Hover color\",defaultValue:\"#000000\"},activeColor:{type:ControlType.Color,title:\"Active color\",defaultValue:\"#0066cc\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"transparent\"},padding:{type:ControlType.Number,title:\"Padding\",defaultValue:16,min:0,max:48,unit:\"px\"},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:8,min:0,max:24,unit:\"px\"},indentH3:{type:ControlType.Number,title:\"H3 indent\",defaultValue:16,min:0,max:48,unit:\"px\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:8,min:0,max:24,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TableOfContents\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"200\",\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\",\"framerIntrinsicWidth\":\"280\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TOC.map"],"mappings":"2NAAwL,SAAS,EAAQ,EAAK,CAAC,OAAO,EAAK,MAAM,CAAC,aAAa,CAAC,QAAQ,OAAO,IAAI,CAAC,QAAQ,cAAc,GAAG,CAAC,QAAQ,MAAM,IAAI,CAAC,QAAQ,SAAS,GAAG,EAAE,UAAW,SAAS,EAAe,EAAG,EAAS,CAAC,IAAI,EAAI,EAAO,EAAE,EAAE,KAAM,EAAS,IAAI,EAAI,EAAE,GAAG,EAAE,EAAI,GAAG,EAAG,GAAG,IAAuB,OAAlB,EAAS,IAAI,EAAI,CAAQ,EAAK,SAAS,EAAa,EAAK,EAAQ,CAAC,IAAI,EAAG,EAAK,cAAc,KAAM,GAAI,IAAK,SAAS,MAAK,CAAC,IAAM,EAAS,EAAG,iBAAi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