{"version":3,"file":"TableOfContents.C2ILUHa3.mjs","names":["useState","_Fragment","__esmMin","init_npm_react_18_3_1","init_ssg_sandbox_shims","ce","init_jsx_runtime","c","p","_e","createStore","init_store_js__1_0","HEADINGS","formatHeading","formatTableOfContent","formatHeadings","init_Utils","formattedHeading","formattedId","children","item","index","result","type","newChildren","props","newItem","withContent","store","setStore","useStore","newProps","setNewProps","l","SCROLL_MARGIN_TOP","Component","init_TableOfContents"],"sources":["https:/framerusercontent.com/modules/1XxWQwY0hfK0NPkccp4R/KJkJpnADqLZBYSaIILnx/Utils.js","https:/framerusercontent.com/modules/VgSLIliIqcoMHUAZB3po/Mir7PCMllgsAe445r5am/TableOfContents.js"],"sourcesContent":["export const HEADINGS=[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"];const formatHeading=(children,index)=>{let formattedHeading=\"\";let formattedId=\"\";if(typeof children===\"string\"){formattedHeading=children;}else if(Array.isArray(children)){formattedHeading=children.map(item=>{var _item_props;if(typeof item===\"string\")return item.trim();if(typeof((_item_props=item.props)===null||_item_props===void 0?void 0:_item_props.children)===\"string\")return item.props.children.trim();}).join(\" \");}else if(typeof children===\"object\"){if(typeof children.props.children===\"string\"){formattedHeading=children.props.children;}else{formattedHeading=children.type;}}else{formattedHeading=index.toString();}formattedId=formattedHeading.toLowerCase().replace(/[^a-z0-9]+/g,\"-\").replace(/^-+|-+$/g,\"\").trim();return{formattedId,formattedHeading};};export const formatTableOfContent=children=>{const result=[];children.length>0&&children.filter(({type})=>HEADINGS.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;};export const formatHeadings=props=>{const newChildren=[];props.children.props.children.forEach((item,index)=>{const children=item.props.children;if(HEADINGS.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{newChildren.push(item);}});// Return a new props object with the modified children\nreturn{...props,children:{...props.children,props:{...props.children.props,children:newChildren}}};};\nexport const __FramerMetadata__ = {\"exports\":{\"formatTableOfContent\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"HEADINGS\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"formatHeadings\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Utils.map","import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{createElement as _createElement}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{useEffect,useState}from\"react\";import{formatHeadings,formatTableOfContent}from\"https://framer.com/m/Utils-WIyM.js\";const HEADING_TO_DISPLAY=[\"h2\",\"h3\"];const SCROLL_MARGIN_TOP=160;const useStore=createStore({headings:[]});export function withTableOfContent(Component){return props=>{const[store]=useStore();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__*/_createElement(Component,{...props,key:id,variant:type,title:heading,link:`${window.location.pathname}#${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(()=>{setNewProps(formatHeadings(props));},[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})]});};}\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=./TableOfContents.map"],"mappings":"A,gPAAa,EAAS,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,IAAI,EAAQ,GAAe,EAAS,IAAQ,CAAC,IAAIiB,EAAiB,GAAOC,EAAY,GAAsoB,MAAnoB,CAA4fD,EAAzf,OAAOE,GAAW,SAA2BA,EAAkB,MAAM,QAAQA,CAAQ,EAAoBA,EAAS,IAAI,GAAM,CAAiB,GAAG,OAAOC,GAAO,SAAS,OAAOA,EAAK,KAAK,EAAE,GAAG,OAAoBA,EAAK,OAAuD,UAAY,SAAS,OAAOA,EAAK,MAAM,SAAS,KAAK,CAAE,CAAC,CAAC,CAAC,KAAK,GAAG,EAAW,OAAOD,GAAW,SAAa,OAAOA,EAAS,MAAM,UAAW,SAA2BA,EAAS,MAAM,SAAgCA,EAAS,KAA6BE,EAAM,SAAS,EAAG,EAAYJ,EAAiB,YAAY,CAAC,CAAC,QAAQ,cAAc,GAAG,CAAC,CAAC,QAAQ,WAAW,EAAE,CAAC,CAAC,KAAK,EAAQ,CAAC,cAAY,kBAAgB,CAAE,EAAe,EAAqB,GAAU,CAAC,IAAMK,EAAO,CAAC,EAA6R,OAA3RH,EAAS,OAAO,GAAGA,EAAS,QAAQ,CAAC,UAAQP,EAAS,SAASW,CAAI,CAAC,CAAC,CAAC,KAAK,EAAK,IAAQ,CAAC,IAAMJ,EAASC,EAAK,MAAM,SAAc,CAAC,cAAY,oBAAkBP,EAAcM,EAASE,CAAK,EAAEC,EAAO,KAAK,CAAC,GAAGJ,EAAY,QAAQD,EAAiB,KAAKG,EAAK,KAAK,cAAcC,CAAK,CAAC,CAAE,CAAC,EAASC,CAAO,EAAe,EAAe,GAAO,CAAC,IAAME,EAAY,CAAC,EAEjtC,OAFmtCC,EAAM,SAAS,MAAM,S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