{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/ExdraRfR4cVvDg6McUjQ/pJo4VWqWTHrNkyNvUxCg/TableOfContent.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,useRef}from\"react\";// Made with love by Cl\u00E9ment. https://lionneclement.com/\n// Full tutorial: https://lionneclement.com/tutorial/how-to-create-table-of-contents-cms-collections-framer\n//UPDATE:\n//This is a modified version in collaboration with Tay Rush. https://twitter.com/taylorrushmore\n// https://www.youtube.com/@taylorrushmore/\nconst HEADING_TO_DISPLAY=[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"];const SCROLL_MARGIN_TOP=80;const useStore=createStore({headings:[]});const scrollToId=id=>{const element=document.getElementById(id);if(element){element.scrollIntoView({behavior:\"smooth\"});}};const openLightbox=img=>{const lightbox=document.createElement(\"div\");lightbox.style.position=\"fixed\";lightbox.style.top=\"0\";lightbox.style.left=\"0\";lightbox.style.width=\"100%\";lightbox.style.height=\"100%\";lightbox.style.backgroundColor=\"rgba(0, 0, 0, 0.8)\";lightbox.style.display=\"flex\";lightbox.style.justifyContent=\"center\";lightbox.style.alignItems=\"center\";lightbox.style.zIndex=\"9999\";const lightboxImg=img.cloneNode();lightboxImg.style.width=\"80%\";lightboxImg.style.maxHeight=\"80%\";lightboxImg.style.objectFit=\"contain\";lightbox.appendChild(lightboxImg);document.body.appendChild(lightbox);// Close lightbox on click\nlightbox.addEventListener(\"click\",()=>{document.body.removeChild(lightbox);});};const Delayed=({children,waitBeforeShow=5500})=>{const[isShown,setIsShown]=useState(false);useEffect(()=>{const timer=setTimeout(()=>{setIsShown(true);},waitBeforeShow);return()=>clearTimeout(timer);},[waitBeforeShow]);return isShown?children:null;};export function withTableOfContent(Component){return props=>{const[store]=useStore();const[activeSection,setActiveSection]=useState(\"\");useEffect(()=>{const handleScroll=()=>{const sections=store.headings.map(heading=>document.getElementById(heading.id));const scrollPosition=window.scrollY-780;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 ref=useRef(null);useEffect(()=>{if(ref.current){const images=ref.current.querySelectorAll(\".framer-image\");images.forEach(img=>{img.addEventListener(\"click\",()=>openLightbox(img));});}},[]);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)=>{if([\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"ol\"].includes(item.type)){var _item_props_children_props_children,_item_props_children_props,_item_props_children;let start=\"\";if(item.type==\"ol\"&&[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"].includes((_item_props_children=item.props.children)===null||_item_props_children===void 0?void 0:(_item_props_children_props=_item_props_children.props)===null||_item_props_children_props===void 0?void 0:(_item_props_children_props_children=_item_props_children_props.children)===null||_item_props_children_props_children===void 0?void 0:_item_props_children_props_children.type)){start=item.props.start||1;item=item.props.children.props.children;}const children=item.props.children;const{formattedId}=formatHeading(start?`${start}. ${children}`:children,index);// Create a new object for the modified item\nconst newItem={...item,start:1,props:{...item.props,children:start?/*#__PURE__*/_jsx(\"ol\",{start:start,children:/*#__PURE__*/_jsx(\"li\",{children:item.props.children})}):item.props.children,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,ref:ref})]});};}const formatTableOfContent=children=>{const result=[];children.length>0&&children.filter(({type})=>[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"].includes(type)).map((item,index)=>{let 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=\"\";console.log(children);if(typeof children===\"string\"){formattedHeading=children;}else if(Array.isArray(children)){formattedHeading=children.map(item=>{if(typeof item===\"string\")return item.trim();if(item.type===\"br\")return\"\";if(item.type===\"li\")return\"\";return item.props.children.trim();}).join(\" \");}else if(typeof children===\"object\"){if(typeof children.props.children===\"string\"){formattedHeading=children.props.children;}if(children.type==\"ol\"){formattedHeading=`${children.props.start}. ${children.props.children.props.children}`;}}else{formattedHeading=index.toString();}formattedId=formattedHeading.trim().toLowerCase().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=./TableOfContent.map"],
  "mappings": "8JAKA,IAAMA,EAAmB,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,IAAI,EAA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Content", "Component", "props", "store", "useStore", "activeSection", "setActiveSection", "ye", "ue", "handleScroll", "sections", "heading", "scrollPosition", "window", "i", "p", "l", "a", "b", "type", "HEADING_TO_DISPLAY", "id", "index", "scrollToId", "withContent", "ref", "pe", "img", "openLightbox", "setStore", "newProps", "setNewProps", "formatTableOfContent", "newChildren", "item", "_item_props_children_props_children", "_item_props_children_props", "_item_props_children", "start", "children", "formattedId", "formatHeading", "newItem", "u", "SCROLL_MARGIN_TOP", "result", "formattedHeading"]
}
