{"version":3,"file":"TableOfContent.3Knb3IB7.mjs","names":["useState","_Fragment","__esmMin","init_ssg_sandbox_shims","init_npm_react_18_3_1","init_jsx_runtime","c","p","ce","_e","init_store_js__1_0","createStore","withContent","store","setStore","useStore","newProps","setNewProps","props","formatTableOfContent","newChildren","children","item","formatHeading","index","newItem","formattedId","isPlatformComparisonTable","tableText","comparisonTableText","label","l","SCROLL_MARGIN_TOP","Component","init_TableOfContent","node","result","type","formattedHeading"],"sources":["https:/framerusercontent.com/modules/a3VG9s3iUm0YoyEF2rgV/NYbuebzJczm3XWH1BK97/TableOfContent.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";// @ts-expect-error Framer resolves this hosted store module at runtime; URL-module typings are unavailable.\nimport{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{useEffect,useState}from\"react\";const HEADING_TO_DISPLAY=[\"h1\",\"h2\"];const SCROLL_MARGIN_TOP=80;const comparisonTableText=node=>{if(typeof node===\"string\"||typeof node===\"number\")return String(node);if(Array.isArray(node))return node.map(comparisonTableText).join(\" \");return node?.props?comparisonTableText(node.props.children):\"\";};const isPlatformComparisonTable=node=>[\"Databricks Genie\",\"Snowflake Cortex Analyst / Agents\",\"Google\"].every(label=>comparisonTableText(node).includes(label));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(()=>{const handleScroll=()=>{const sections=store.headings.map(heading=>document.getElementById(heading.id));const scrollPosition=window.scrollY-160;for(let i=sections.length-1;i>=0;i--){if(sections[i].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&&window?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,onClick:()=>scrollToId(id)})):/*#__PURE__*/_jsx(Component,{...props})});};}export function withContent(Component){return props=>{const[store,setStore]=useStore();const[newProps,setNewProps]=useState(props);useEffect(()=>{setStore({headings:formatTableOfContent(newProps.children.props.children)});},[newProps]);useEffect(()=>{const formatHeadings=()=>{const newChildren=[];props.children.props.children.length>0&&props.children.props.children.forEach((item,index)=>{const children=item.props.children;if([\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"].includes(item.type)){const{formattedId}=formatHeading(children,index);// Create a new object for the modified item\nconst newItem={...item,props:{...item.props,id:formattedId}};newChildren.push(newItem);}else if(isPlatformComparisonTable(item)){const tableText=comparisonTableText(item);const label=tableText.includes(\"Approche\")?\"Tableau comparatif\":tableText.includes(\"Aanpak\")?\"Vergelijkingstabel\":\"Comparison table\";newChildren.push(/*#__PURE__*/_jsx(\"div\",{role:\"region\",\"aria-label\":label,tabIndex:0,style:{width:\"100%\",maxWidth:\"100%\",minWidth:0,overflowX:\"auto\",WebkitOverflowScrolling:\"touch\"},children:/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",minWidth:600},children:item})},item.key??`comparison-table-${index}`));}else{newChildren.push(item);}});// Return a new props object with the modified children\nreturn{...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})]});};}const formatTableOfContent=children=>{const result=[];children.length>0&&children.filter(({type})=>[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"].includes(type)).map((item,index)=>{const children=item.props.children;const{formattedId,formattedHeading}=formatHeading(children,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=>{console.log(\"item\",item);if(typeof item===\"string\")return item.trim();if(item.type===\"br\")return\"\";return item.props.children.trim();}).join(\" \");}else if(typeof children===\"object\"){if(typeof children.props.children===\"string\"){formattedHeading=children.props.children;}}else{formattedHeading=index.toString();}formattedId=formattedHeading.trim().toLowerCase().replace(/[^a-z]+/g,\"-\").replace(/^-+|-+$/g,\"\");return{formattedId,formattedHeading};};\nexport const __FramerMetadata__ = {\"exports\":{\"withContent\":{\"type\":\"reactHoc\",\"name\":\"withContent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withTableOfContent\":{\"type\":\"reactHoc\",\"name\":\"withTableOfContent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TableOfContent.map"],"mappings":"A,sMACopD,SAAgBY,EAAY,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAACC,EAAMC,GAAUC,EAAS,EAAO,CAACC,EAASC,GAAajB,EAASkB,CAAK,EAEvoD,OAFyoDV,MAAc,CAACM,EAAS,CAAC,SAASK,EAAqBH,EAAS,SAAS,MAAM,QAAQ,CAAC,CAAC,CAAE,EAAE,CAACA,CAAQ,CAAC,EAAER,MAAc,CAEzyDS,OAFm0D,CAAC,IAAMG,EAAY,CAAC,EAE57D,OAF87DF,EAAM,SAAS,MAAM,SAAS,OAAO,GAAGA,EAAM,SAAS,MAAM,SAAS,SAAS,EAAK,IAAQ,CAAC,IAAMG,EAASC,EAAK,MAAM,SAAS,GAAG,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,IAAI,CAAC,CAAC,SAASA,EAAK,IAAI,EAAE,CAAC,GAAK,CAAC,eAAaC,EAAcF,EAASG,CAAK,EAC/pEC,E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