{"version":3,"file":"Table_of_Content.H_4APIjc.mjs","names":["useState","_Fragment"],"sources":["https:/framerusercontent.com/modules/g2f8tI5t0j0EN31cCqX8/iN2T9XXVUneAc1xxzKDY/Table_of_Content.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{useEffect,useState}from\"react\";const HEADING_TO_DISPLAY=[\"h2\",\"h3\",\"h4\",\"h5\"];const SCROLL_MARGIN_TOP=100;const useStore=createStore({headings:[]});export function withTableOfContent(Component){return props=>{const[store]=useStore();const[activeSection,setActiveSection]=useState(\"\");const scrollToId=id=>{const element=document.getElementById(id);if(element){element.scrollIntoView({behavior:\"smooth\"});}};useEffect(()=>{if(!store.headings||store.headings.length===0)return;const handleScroll=()=>{const sections=store.headings.map(heading=>document.getElementById(heading.id));const scrollPosition=window.scrollY-SCROLL_MARGIN_TOP;for(let i=sections.length-1;i>=0;i--){const section=sections[i];if(!section)continue;if(section.offsetTop<=scrollPosition){setActiveSection(store.headings[i].id);break;}}};window.addEventListener(\"scroll\",handleScroll);return()=>{window.removeEventListener(\"scroll\",handleScroll);};},[store.headings]);return /*#__PURE__*/_jsx(_Fragment,{children:store.headings.length>0&&typeof window!==\"undefined\"?store.headings.sort((a,b)=>a.originalIndex-b.originalIndex).filter(({type})=>HEADING_TO_DISPLAY.includes(type)).map(({id,heading,type},index)=>/*#__PURE__*/_jsx(Component,{...props,variant:activeSection===id?`${type}-active`:type,title:heading,link:`${window.location.pathname}#${id}`,onClick:()=>scrollToId(id)},id??index)):/*#__PURE__*/_jsx(Component,{...props})});};}export function withContent(Component){return props=>{const[store,setStore]=useStore();const[newProps,setNewProps]=useState(props);useEffect(()=>{if(!newProps?.children||!newProps.children.props||!newProps.children.props.children)return;setStore({headings:formatTableOfContent(newProps.children.props.children)});},[newProps]);useEffect(()=>{const formatHeadings=()=>{const originalChildren=props.children?.props?.children??[];const childrenArray=Array.isArray(originalChildren)?originalChildren:[originalChildren];const newChildren=[];childrenArray.forEach((item,index)=>{if(!item||!item.type){newChildren.push(item);return;}const children=item.props?.children;if([\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"].includes(item.type)){const{formattedId}=formatHeading(children,index);const newItem={...item,props:{...item.props,id:formattedId}};newChildren.push(newItem);}else{newChildren.push(item);}});return{...props,children:{...props.children,props:{...props.children.props,children:newChildren}}};};setNewProps(formatHeadings());},[props]);return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:`.framer-text {\n                    scroll-margin-top: ${SCROLL_MARGIN_TOP}px;\n                }`}),/*#__PURE__*/_jsx(Component,{...newProps})]});};}/** Utility: normalize smart quotes into plain quotes */const normalizeSmartQuotes=str=>str.replace(/[“”«»„‟]/g,'\"').replace(/[‘’‚‛]/g,\"'\");const formatTableOfContent=children=>{const result=[];const childrenArray=Array.isArray(children)?children:[children];childrenArray.filter(item=>item&&item.type&&[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"].includes(item.type)).forEach((item,index)=>{const childContent=item.props?.children;const{formattedId,formattedHeading}=formatHeading(childContent,index);result.push({id:formattedId,heading:formattedHeading,type:item.type,originalIndex:index});});return result;};const formatHeading=(children,index)=>{let formattedHeading=\"\";let formattedId=\"\";if(typeof children===\"string\"){formattedHeading=children;}else if(Array.isArray(children)){formattedHeading=children.map(item=>{if(typeof item===\"string\")return item.trim();if(!item)return\"\";if(item.type===\"br\")return\"\";const c=item.props?.children;return typeof c===\"string\"?c.trim():\"\";}).join(\" \");}else if(typeof children===\"object\"&&children!==null){const inner=children.props?.children;if(typeof inner===\"string\"){formattedHeading=inner;}else{formattedHeading=children.type??index.toString();}}else{formattedHeading=index.toString();}// Normalize smart quotes etc.\nformattedHeading=normalizeSmartQuotes(formattedHeading).trim();// Unicode‑aware slug: normalize accents, keep letters/numbers/parentheses, collapse to hyphens\nformattedId=formattedHeading.toLowerCase().normalize(\"NFKD\").replace(/[\\u0300-\\u036f]/g,\"\").replace(/[^a-z0-9()]+/g,\"-\").replace(/^-+|-+$/g,\"\");return{formattedId,formattedHeading};};\nexport const __FramerMetadata__ = {\"exports\":{\"withTableOfContent\":{\"type\":\"reactHoc\",\"name\":\"withTableOfContent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withContent\":{\"type\":\"reactHoc\",\"name\":\"withContent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Table_of_Content.map"],"mappings":"wMAA+S,SAAgB,EAAmB,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAAC,GAAO,GAAU,CAAM,CAAC,EAAc,GAAkBA,EAAS,GAAG,CAAO,EAAW,GAAI,CAAC,IAAM,EAAQ,SAAS,eAAe,EAAG,CAAI,GAAS,EAAQ,eAAe,CAAC,SAAS,SAAS,CAAC,EAAohB,OAAhhB,MAAc,CAAC,GAAG,CAAC,EAAM,UAAU,EAAM,SAAS,SAAS,EAAE,OAAO,IAAM,MAAiB,CAAC,IAAM,EAAS,EAAM,SAAS,IAAI,GAAS,SAAS,eAAe,EAAQ,GAAG,CAAC,CAAO,EAAe,EAAO,QAAQ,EAAkB,IAAI,IAAI,EAAE,EAAS,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,IAAM,EAAQ,EAAS,GAAO,MAAoB,EAAQ,WAAW,EAAe,CAAC,EAAiB,EAAM,SAAS,GAAG,GAAG,CAAC,SAAyD,OAA/C,EAAO,iBAAiB,SAAS,EAAa,KAAW,CAAC,EAAO,oBAAoB,SAAS,EAAa,GAAK,CAAC,EAAM,SAAS,CAAC,CAAqB,EAAKC,EAAU,CAAC,SAAS,EAAM,SAAS,OAAO,GAAU,IAAS,OAAY,EAAM,SAAS,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,cAAc,CAAC,QAAQ,CAAC,UAAQ,EAAmB,SAAS,EAAK,CAAC,CAAC,KAAK,C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