{"version":3,"file":"TableOfContent.DYKUP4Ds.mjs","names":["headers"],"sources":["https:/framerusercontent.com/modules/q6TPcm1rVRPb4ymPsf0M/ozVL167hH9qRZk4f9yzV/TableOfContent.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerIntrinsicWidth 600\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerIntrinsicHeight 400\n */export default function Table_of_Content(props){const[headers,setHeaders]=useState([]);const[activeId,setActiveId]=useState(\"\");const[firstHeadingLevel,setFirstHeadingLevel]=useState(null);const ignoreNextScrollEvent=useRef(false);const scrollTimeoutRef=useRef(null);useEffect(()=>{const sectionElement=document.getElementById(props.section_id)||document.body;const headingElements=Array.from(sectionElement.querySelectorAll(\"h1, h2, h3, h4, h5, h6\"));if(headingElements.length>0&&firstHeadingLevel===null){setFirstHeadingLevel(parseInt(headingElements[0].tagName[1],10));}const headers=headingElements.map((element,index)=>{if(!element.id){element.id=`header-${index}`;}return{id:element.id,text:element.innerText,level:parseInt(element.tagName[1],10)};});setHeaders(headers);},[props.section_id,firstHeadingLevel]);useEffect(()=>{const onScroll=()=>{if(ignoreNextScrollEvent.current){ignoreNextScrollEvent.current=false;return;}let currentSectionId=\"\";headers.filter(header=>props[`showH${header.level}`]!==false).forEach(header=>{const element=document.getElementById(header.id);const scrollPosition=element.getBoundingClientRect().top+window.scrollY;if(scrollPosition<window.scrollY+props.yOffset+5){currentSectionId=header.id;}});setActiveId(currentSectionId);};window.addEventListener(\"scroll\",onScroll);return()=>window.removeEventListener(\"scroll\",onScroll);},[headers,props.yOffset,props]);const getStyle=header=>{const indentation=firstHeadingLevel?header.level-firstHeadingLevel:0;const headerFont=props[`h${header.level}Font`]||{};return{display:\"block\",...headerFont,color:header.id===activeId?props.activeColor:props.fontColor,fontWeight:header.id===activeId?props.activeFontWeight:headerFont.fontWeight||\"normal\",textDecoration:\"none\",marginBottom:`${props.spacing}px`,marginLeft:`${indentation*props.indentation}px`};};const handleClick=headerId=>{ignoreNextScrollEvent.current=true;const element=document.getElementById(headerId);if(element){const y=element.getBoundingClientRect().top+window.pageYOffset-props.yOffset;window.scrollTo({top:y,behavior:\"smooth\"});checkIfScrollFinished(headerId);}};const checkIfScrollFinished=headerId=>{if(scrollTimeoutRef.current){clearTimeout(scrollTimeoutRef.current);}const isScrolled=()=>{const element=document.getElementById(headerId);if(element){const rect=element.getBoundingClientRect();return Math.abs(rect.top-props.yOffset)<=1;}return false;};const checkScroll=()=>{if(isScrolled()){setActiveId(headerId);}else{scrollTimeoutRef.current=setTimeout(()=>{requestAnimationFrame(checkScroll);},10);}};checkScroll();};return /*#__PURE__*/_jsx(\"div\",{children:headers.filter(header=>props[`showH${header.level}`]!==false).map(header=>/*#__PURE__*/_jsx(\"a\",{href:`#${header.id}`,style:getStyle(header),onMouseOver:e=>e.currentTarget.style.color=props.onHoverColor,onMouseOut:e=>{e.currentTarget.style.color=header.id===activeId?props.activeColor:props.fontColor;e.currentTarget.style.fontWeight=header.id===activeId?props.activeFontWeight:getStyle(header).fontWeight;},onClick:e=>{e.preventDefault();handleClick(header.id);},children:header.text},header.id))});}Table_of_Content.defaultProps={section_id:\"\",fontColor:\"#000000\",activeColor:\"#FF0000\",onHoverColor:\"#00FF00\",spacing:8,indentation:10,yOffset:0,activeFontWeight:\"bold\"};addPropertyControls(Table_of_Content,{section_id:{type:ControlType.String,title:\"Section ID\"},fontColor:{type:ControlType.Color,title:\"Font Color\"},activeColor:{type:ControlType.Color,title:\"Active Color\"},onHoverColor:{type:ControlType.Color,title:\"On Hover Color\"},spacing:{type:ControlType.Number,title:\"Spacing\"},indentation:{type:ControlType.Number,title:\"Indentation\"},yOffset:{type:ControlType.Number,title:\"Y Offset\",min:0,max:200,step:1},activeFontWeight:{type:ControlType.Enum,title:\"Active Font Weight\",options:[\"normal\",\"bold\",\"bolder\",\"lighter\",\"100\",\"200\",\"300\",\"400\",\"500\",\"600\",\"700\",\"800\",\"900\"],defaultValue:\"bold\"},showH1:{type:ControlType.Boolean,title:\"Show H1\",defaultValue:true},showH2:{type:ControlType.Boolean,title:\"Show H2\",defaultValue:true},showH3:{type:ControlType.Boolean,title:\"Show H3\",defaultValue:true},showH4:{type:ControlType.Boolean,title:\"Show H4\",defaultValue:true},showH5:{type:ControlType.Boolean,title:\"Show H5\",defaultValue:true},showH6:{type:ControlType.Boolean,title:\"Show H6\",defaultValue:true},h1Font:{// @ts-expect-error – Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H1 Font\"},h2Font:{// @ts-expect-error – Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H2 Font\"},h3Font:{// @ts-expect-error – Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H3 Font\"},h4Font:{// @ts-expect-error – Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H4 Font\"},h5Font:{// @ts-expect-error – Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H5 Font\"},h6Font:{// @ts-expect-error – Internal\ntype:ControlType.Font,controls:\"extended\",title:\"H6 Font\",description:\"Preview to see it in effect \\n\\nv1.6 \\n[via SegmentUI](https://www.segmentUI.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Table_of_Content\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"400\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"600\",\"framerDisableUnlink\":\"*\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TableOfContent.map"],"mappings":"0TAOG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,EAAQ,EAAW,CAAC,EAAS,CAAE,EAAC,CAAM,CAAC,EAAS,EAAY,CAAC,EAAS,G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