{"version":3,"file":"ArticleJumpLinks.21Itk-Ri.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/TMvQYgBuuOY1P4RXowjM/0M1FjiCuWINFZoaFjHE3/ArticleJumpLinks.js"],"sourcesContent":["// Article Jump Links Component - Dynamically generates navigation links from H2 and H3 headings in article content\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";function JumpLink({listNumber,title,targetId,level,isActive,numberFontFamily,numberFontSize,numberColor,titleFontFamily,titleFontSize,titleLineHeight,titleColor,borderColor,showNumbers,indentSubheadings,indentSize,showActiveIndicator}){const handleClick=e=>{e.preventDefault();e.stopPropagation();const targetElement=document.getElementById(targetId);if(targetElement){targetElement.scrollIntoView({behavior:\"smooth\",block:\"start\"});}};const isSubheading=level===3;const leftPadding=indentSubheadings&&isSubheading?indentSize:0;const showNumberForThisItem=showNumbers&&!isSubheading;return /*#__PURE__*/_jsxs(\"div\",{onClick:handleClick,style:{display:\"grid\",gridTemplateColumns:showNumberForThisItem?\"40px 1fr\":\"1fr\",gap:showNumberForThisItem?\"12px\":\"0px\",padding:\"8px 0\",paddingLeft:`${leftPadding}px`,cursor:\"pointer\",borderBottom:`1px solid ${borderColor||\"#e5e5e5\"}`,alignItems:\"flex-start\",userSelect:\"none\",backgroundColor:\"transparent\",transition:\"all 0.2s ease\"},children:[showNumberForThisItem&&/*#__PURE__*/_jsx(\"div\",{style:{width:\"40px\",fontFamily:numberFontFamily||\"JetBrains Mono, monospace\",fontSize:`${numberFontSize||14}px`,color:isActive&&showActiveIndicator?\"rgb(15, 25, 36)\":numberColor||\"#666\",fontWeight:isActive&&showActiveIndicator?\"500\":\"normal\"},children:listNumber}),/*#__PURE__*/_jsx(\"div\",{style:{fontFamily:titleFontFamily||\"inherit\",fontSize:`${(titleFontSize||14)-(isSubheading?1:0)}px`,lineHeight:titleLineHeight||1.5,color:isActive&&showActiveIndicator?\"rgb(15, 25, 36)\":titleColor||\"#333\",fontWeight:isActive&&showActiveIndicator?\"500\":\"400\",opacity:isSubheading?.8:1},children:title})]});}// Extract headings from a container element and return JumpLinkData[]\nfunction extractHeadings(container,headingSelector){const headings=container.querySelectorAll(headingSelector);const sectionData=[];headings.forEach((heading,index)=>{const level=parseInt(heading.tagName.charAt(1));let id=heading.id;if(!id){const text=heading.textContent||\"\";id=`heading-${text.toLowerCase().replace(/[^a-z0-9]+/g,\"-\").replace(/^-+|-+$/g,\"\")}-${index}`;heading.id=id;}const title=heading.textContent?.trim()||\"\";if(title)sectionData.push({id,title,level});});return sectionData;}// Find the first element matching a selector that actually contains headings\nfunction findContainerWithHeadings(selector,headingSelector){const candidates=document.querySelectorAll(selector);for(const el of Array.from(candidates)){if(el.querySelectorAll(headingSelector).length>0)return el;}return null;}/**\n * Article Jump Links - Dynamically generates navigation from H2 and H3 headings\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function ArticleJumpLinks({width=304,height=\"fit-content\",gap=0,numberFontFamily=\"JetBrains Mono, monospace\",numberFontSize=14,numberColor=\"#666\",titleFontFamily=\"inherit\",titleFontSize=14,titleLineHeight=1.5,titleColor=\"#333\",borderColor=\"#e5e5e5\",showNumbers=true,indentSubheadings=true,indentSize=20,activeColor=\"#0066FF\",showActiveIndicator=true,includeH3=true,contentSelector=\"\"}){const[jumpLinks,setJumpLinks]=useState([]);const[activeId,setActiveId]=useState(\"\");const componentRef=useRef(null);useEffect(()=>{const findArticleHeadings=()=>{const currentElement=componentRef.current;if(!currentElement)return[];const headingSelector=includeH3?\"h2, h3\":\"h2\";// Strategy 0: Explicit contentSelector prop — always wins if set\nif(contentSelector&&contentSelector.trim()){const target=findContainerWithHeadings(contentSelector.trim(),headingSelector);if(target)return extractHeadings(target,headingSelector);}// Strategy 1: Framer CMS rich text container — the article body in Framer\n// is always rendered inside a [data-framer-name=\"Content\"] div.\n// We pick the first one that actually contains headings.\nconst framerContent=findContainerWithHeadings('[data-framer-name=\"Content\"]',headingSelector);if(framerContent)return extractHeadings(framerContent,headingSelector);// Strategy 2: First sibling of our parent that contains headings\nconst parent=currentElement.parentElement;if(parent){for(const sibling of Array.from(parent.children)){if(sibling===currentElement)continue;if(sibling.querySelectorAll(headingSelector).length>0){return extractHeadings(sibling,headingSelector);}}}// Strategy 3: First sibling of grandparent that contains headings\nif(parent?.parentElement){for(const parentSibling of Array.from(parent.parentElement.children)){if(parentSibling===parent)continue;if(parentSibling.querySelectorAll(headingSelector).length>0){return extractHeadings(parentSibling,headingSelector);}}}// Strategy 4: Common article content selectors\nfor(const selector of['[role=\"article\"]',\"article\",\".content\",\".article-content\",\"#content\",\"main\",\"[data-content]\"]){const el=document.querySelector(selector);if(el&&el.querySelectorAll(headingSelector).length>0){return extractHeadings(el,headingSelector);}}// Strategy 5: Entire body as last resort\nreturn extractHeadings(document.body,headingSelector);};const updateJumpLinks=()=>setJumpLinks(findArticleHeadings());const timeoutId=setTimeout(updateJumpLinks,500);const interval=setInterval(updateJumpLinks,2e3);return()=>{clearTimeout(timeoutId);clearInterval(interval);};},[includeH3,contentSelector]);// Track active section on scroll\nuseEffect(()=>{if(!showActiveIndicator||jumpLinks.length===0)return;const handleScroll=()=>{const scrollPosition=window.scrollY+100;let currentActiveId=\"\";for(let i=jumpLinks.length-1;i>=0;i--){const element=document.getElementById(jumpLinks[i].id);if(element){const elementTop=element.getBoundingClientRect().top+window.scrollY;if(elementTop<=scrollPosition){currentActiveId=jumpLinks[i].id;break;}}}if(currentActiveId!==activeId)setActiveId(currentActiveId);};window.addEventListener(\"scroll\",handleScroll,{passive:true});handleScroll();return()=>window.removeEventListener(\"scroll\",handleScroll);},[jumpLinks,activeId,showActiveIndicator]);return /*#__PURE__*/_jsx(\"div\",{ref:componentRef,style:{width:typeof width===\"number\"?`${width}px`:width,height:typeof height===\"number\"?`${height}px`:height,display:\"flex\",flexDirection:\"column\",gap:`${gap}px`},children:jumpLinks.length>0?jumpLinks.map((link,index)=>{const h2Index=jumpLinks.slice(0,index+1).filter(l=>l.level===2).length;return /*#__PURE__*/_jsx(JumpLink,{listNumber:String(h2Index).padStart(2,\"0\"),title:link.title,targetId:link.id,level:link.level,isActive:activeId===link.id,numberFontFamily:numberFontFamily,numberFontSize:numberFontSize,numberColor:numberColor,titleFontFamily:titleFontFamily,titleFontSize:titleFontSize,titleLineHeight:titleLineHeight,titleColor:titleColor,borderColor:borderColor,showNumbers:showNumbers,indentSubheadings:indentSubheadings,indentSize:indentSize,activeColor:activeColor,showActiveIndicator:showActiveIndicator},link.id);}):/*#__PURE__*/_jsxs(\"div\",{style:{padding:\"16px\",backgroundColor:\"#f5f5f5\",color:\"#666\",textAlign:\"center\",fontSize:\"14px\",borderRadius:\"4px\"},children:[\"No headings found in article content\",/*#__PURE__*/_jsx(\"br\",{}),/*#__PURE__*/_jsxs(\"small\",{style:{opacity:.7},children:[\"Scanning for \",includeH3?\"H2 and H3\":\"H2\",\" elements...\"]})]})});}addPropertyControls(ArticleJumpLinks,{gap:{type:ControlType.Number,title:\"Gap\",defaultValue:0,min:0,max:50,step:1},includeH3:{type:ControlType.Boolean,title:\"Include H3 Headings\",defaultValue:true,enabledTitle:\"Include\",disabledTitle:\"H2 Only\"},showNumbers:{type:ControlType.Boolean,title:\"Show Numbers\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},numberFontFamily:{type:ControlType.String,title:\"Number Font Family\",defaultValue:\"JetBrains Mono, monospace\",placeholder:\"JetBrains Mono, monospace\",hidden:props=>!props.showNumbers},numberFontSize:{type:ControlType.Number,title:\"Number Font Size\",defaultValue:14,min:8,max:32,step:1,unit:\"px\",hidden:props=>!props.showNumbers},numberColor:{type:ControlType.Color,title:\"Number Color\",defaultValue:\"#666\",hidden:props=>!props.showNumbers},titleFontFamily:{type:ControlType.String,title:\"Title Font Family\",defaultValue:\"inherit\",placeholder:\"inherit\"},titleFontSize:{type:ControlType.Number,title:\"Title Font Size\",defaultValue:14,min:8,max:32,step:1,unit:\"px\"},titleLineHeight:{type:ControlType.Number,title:\"Title Line Height\",defaultValue:1.5,min:1,max:3,step:.1},titleColor:{type:ControlType.Color,title:\"Title Color\",defaultValue:\"#333\"},borderColor:{type:ControlType.Color,title:\"Border Color\",defaultValue:\"#e5e5e5\"},indentSubheadings:{type:ControlType.Boolean,title:\"Indent H3\",defaultValue:true,enabledTitle:\"Indent\",disabledTitle:\"No Indent\",hidden:props=>!props.includeH3},indentSize:{type:ControlType.Number,title:\"Indent Size\",defaultValue:20,min:0,max:60,step:4,unit:\"px\",hidden:props=>!props.indentSubheadings||!props.includeH3},showActiveIndicator:{type:ControlType.Boolean,title:\"Active Indicator\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},activeColor:{type:ControlType.Color,title:\"Active Color\",defaultValue:\"#0066FF\",hidden:props=>!props.showActiveIndicator},contentSelector:{type:ControlType.String,title:\"Content Selector\",defaultValue:\"\",placeholder:\"e.g. .article-body or #content\",description:\"Optional CSS selector to override automatic detection.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ArticleJumpLinks\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ArticleJumpLinks.map"],"mappings":"8MAC0J,SAAS,EAAS,CAAC,aAAW,QAAM,WAAS,QAAM,WAAS,mBAAiB,iBAAe,cAAY,kBAAgB,gBAAc,kBAAgB,aAAW,cAAY,cAAY,oBAAkB,aAAW,uBAAqB,CAAC,IAAM,EAAY,GAAG,CAAC,EAAE,gBAAgB,CAAC,EAAE,iBAAiB,CAAC,IAAM,EAAc,SAAS,eAAe,EAAS,CAAI,GAAe,EAAc,eAAe,CAAC,SAAS,SAAS,MAAM,QAAQ,CAAC,EAAU,EAAa,IAAQ,EAAQ,EAAY,GAAmB,EA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