{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/YdssnNKDeArgaiNs4wFI/Csk3X3zusmvkCgg2I5Fj/Table_of_Contents_Blog.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=[\"h1\",\"h2\"];const SCROLL_MARGIN_TOP=186;const useStore=createStore({headings:[]});export function withTableOfContent(Component){return props=>{const[store]=useStore();const handleLinkClick=(event,id)=>{event.preventDefault();const targetElement=document.getElementById(id);if(targetElement){targetElement.scrollIntoView({behavior:\"smooth\"});}};return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:`\n                    .toc-link {\n                        text-decoration: none;\n                        color: inherit;\n                    }\n                `}),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(\"a\",{href:`${window.location.pathname}#${id}`,onClick:event=>handleLinkClick(event,id),className:\"toc-link\",children:/*#__PURE__*/_jsx(Component,{...props,variant:type,title:heading})},index)):/*#__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.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{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.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=>{if(typeof item===\"string\")return item.trim();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-z]+/g,\"-\").replace(/^-+|-+$/g,\"\").trim();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_Contents_Blog.map"],
  "mappings": "uJAA0L,IAAMA,EAAmB,CAAC,KAAK,IAAI,EAAQC,EAAkB,IAAUC,EAASC,EAAY,CAAC,SAAS,CAAC,CAAC,CAAC,EAAS,SAASC,EAAmBC,EAAU,CAAC,OAAOC,GAAO,CAAC,GAAK,CAACC,CAAK,EAAEL,EAAS,EAAQM,EAAgB,CAACC,EAAMC,IAAK,CAACD,EAAM,eAAe,EAAE,IAAME,EAAc,SAAS,eAAeD,CAAE,EAAKC,GAAeA,EAAc,eAAe,CAAC,SAA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Aa,OAAOA,EAAS,MAAM,UAAW,SAAUK,EAAiBL,EAAS,MAAM,SAAeK,EAAiBL,EAAS,KAAYK,EAAiBf,EAAM,SAAS,EAAGW,EAAYI,EAAiB,YAAY,EAAE,QAAQ,WAAW,GAAG,EAAE,QAAQ,WAAW,EAAE,EAAE,KAAK,EAAQ,CAAC,YAAAJ,EAAY,iBAAAI,CAAgB,CAAE",
  "names": ["HEADING_TO_DISPLAY", "SCROLL_MARGIN_TOP", "useStore", "createStore", "withTableOfContent", "Component", "props", "store", "handleLinkClick", "event", "id", "targetElement", "u", "l", "p", "window", "a", "b", "type", "heading", "index", "withContent", "setStore", "newProps", "setNewProps", "ye", "ue", "formatTableOfContent", "newChildren", "item", "children", "formattedId", "formatHeading", "newItem", "result", "formattedHeading"]
}
