{
  "version": 3,
  "sources": ["ssg:https://framer.com/m/framer/store.js@^1.0.0", "ssg:https://framerusercontent.com/modules/8VTMMGrxM4nu6VIg0LZv/ckTYBqCPVjNnbrKULsd8/WithTOCAndReadTime.js"],
  "sourcesContent": ["import{useState,useEffect}from\"react\";import{Data,useObserveData}from\"framer\";export function createStore(state1){// Use Data so that a Preview reload resets the state\nconst dataStore=Data({state:Object.freeze({...state1})});// Create a set function that updates the state\nconst setDataStore=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(dataStore.state);}dataStore.state=Object.freeze({...dataStore.state,...newState});};// Store the initial state, copy the object if it's an object\nlet storeState=typeof state1===\"object\"?Object.freeze({...state1}):state1;// Keep a list of all the listeners, in the form of React hook setters\nconst storeSetters=new Set();// Create a set function that updates all the listeners / setters\nconst setStoreState=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(storeState);}storeState=typeof newState===\"object\"?Object.freeze({...storeState,...newState}):newState;// Update all the listeners / setters with the new value\nstoreSetters.forEach(setter=>setter(storeState));};// Create the actual hook based on everything above\nfunction useStore(){// Create the hook we are going to use as a listener\nconst[state,setState]=useState(storeState);// If we unmount the component using this hook, we need to remove the listener\n// @ts-ignore\nuseEffect(()=>{// But right now, we need to add the listener\nstoreSetters.add(setState);return()=>storeSetters.delete(setState);},[]);// If Data context exists, use Data, otherwise use vanilla React state\nif(useObserveData()===true){useObserveData();return[dataStore.state,setDataStore];}else{// Return the state and a function to update the central store\nreturn[state,setStoreState];}}return useStore;}\nexport const __FramerMetadata__ = {\"exports\":{\"createStore\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./createStore.map", "import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";const HEADING_TO_DISPLAY=[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"];const SCROLL_MARGIN_TOP=80;// Store partag\u00E9\nconst useStore=createStore({headings:[],content:\"\",numberOfWords:0});// Utilitaire pour s'assurer que les enfants sont toujours un tableau\nconst normalizeChildren=children=>{if(!children)return[];if(Array.isArray(children))return children;return[children];};// **1. Override pour le contenu**\nexport function withContent(Component){return props=>{const[store,setStore]=useStore();useEffect(()=>{var _props_children_props,_props_children;const children=normalizeChildren((_props_children=props.children)===null||_props_children===void 0?void 0:(_props_children_props=_props_children.props)===null||_props_children_props===void 0?void 0:_props_children_props.children);const headings=children.filter(child=>HEADING_TO_DISPLAY.includes(child===null||child===void 0?void 0:child.type)).map((item,index)=>({id:`${item.props.children}-${index}`,heading:item.props.children,type:item.type}));setStore({headings});},[props.children]);return /*#__PURE__*/_jsx(Component,{...props});};}// **2. Override pour la Table of Content**\nexport 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-SCROLL_MARGIN_TOP;for(let i=sections.length-1;i>=0;i--){if(sections[i]&&sections[i].offsetTop<=scrollPosition){setActiveSection(store.headings[i].id);break;}}};window.addEventListener(\"scroll\",handleScroll);return()=>window.removeEventListener(\"scroll\",handleScroll);},[store.headings]);return /*#__PURE__*/_jsxs(_Fragment,{children:[store.headings.length>0&&/*#__PURE__*/_jsxs(\"div\",{children:[/*#__PURE__*/_jsx(\"h2\",{children:\"Table of Contents\"}),/*#__PURE__*/_jsx(\"ul\",{children:store.headings.map(({id,heading,type})=>/*#__PURE__*/_jsx(\"li\",{style:{fontWeight:activeSection===id?\"bold\":\"normal\"},onClick:()=>scrollToId(id),children:heading},id))})]}),/*#__PURE__*/_jsx(Component,{...props})]});};}// **3. Override pour la dur\u00E9e de lecture**\nexport function withReadTime(Component){return props=>{const[store,setStore]=useStore();useEffect(()=>{var _props_children_props,_props_children;const children=normalizeChildren((_props_children=props.children)===null||_props_children===void 0?void 0:(_props_children_props=_props_children.props)===null||_props_children_props===void 0?void 0:_props_children_props.children);const textContent=children.filter(child=>(child===null||child===void 0?void 0:child.type)===\"p\").map(child=>child.props.children).join(\" \");const wordCount=textContent.split(/\\s+/).length;setStore({content:textContent,numberOfWords:wordCount});},[props.children]);return /*#__PURE__*/_jsx(Component,{...props,readTime:`${Math.ceil(store.numberOfWords/200)} min read`});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withContent\":{\"type\":\"reactHoc\",\"name\":\"withContent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withTableOfContent\":{\"type\":\"reactHoc\",\"name\":\"withTableOfContent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withReadTime\":{\"type\":\"reactHoc\",\"name\":\"withReadTime\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./WithTOCAndReadTime.map"],
  "mappings": "uGAAqF,SAASA,EAAYC,EAAO,CACjH,IAAMC,EAAUC,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAGF,CAAM,CAAC,CAAC,CAAC,EACjDG,EAAaC,GAAU,CAC1B,OAAOA,GAAW,aAAYA,EAASA,EAASH,EAAU,KAAK,GAAGA,EAAU,MAAM,OAAO,OAAO,CAAC,GAAGA,EAAU,MAAM,GAAGG,CAAQ,CAAC,CAAE,EACjIC,EAAW,OAAOL,GAAS,SAAS,OAAO,OAAO,CAAC,GAAGA,CAAM,CAAC,EAAEA,EAC7DM,EAAa,IAAI,IACjBC,EAAcH,GAAU,CAC3B,OAAOA,GAAW,aAAYA,EAASA,EAASC,CAAU,GAAGA,EAAW,OAAOD,GAAW,SAAS,OAAO,OAAO,CAAC,GAAGC,EAAW,GAAGD,CAAQ,CAAC,EAAEA,EACjJE,EAAa,QAAQE,GAAQA,EAAOH,CAAU,CAAC,CAAE,EACjD,SAASI,GAAU,CACnB,GAAK,CAACC,EAAMC,CAAQ,EAAEC,EAASP,CAAU,EAIzC,OAFAQ,EAAU,KACVP,EAAa,IAAIK,CAAQ,EAAQ,IAAIL,EAAa,OAAOK,CAAQ,GAAI,CAAC,CAAC,EACpEG,EAAe,IAAI,IAAMA,EAAe,EAAQ,CAACb,EAAU,MAAME,CAAY,GAC1E,CAACO,EAAMH,CAAa,CAAG,CAAC,OAAOE,CAAS,CCd9C,IAAMM,EAASC,EAAY,CAAC,SAAS,CAAC,EAAE,QAAQ,GAAG,cAAc,CAAC,CAAC,EAC7DC,EAAkBC,GAAeA,EAAqB,MAAM,QAAQA,CAAQ,EAASA,EAAe,CAACA,CAAQ,EAA7D,CAAC,EAGhD,SAASC,EAAaC,EAAU,CAAC,OAAOC,GAAO,CAAC,GAAK,CAACC,EAAMC,CAAQ,EAAEC,EAAS,EAAE,OAAAC,EAAU,IAAI,CAAC,IAAIC,EAAsBC,EAAsP,IAAMC,EAA7NC,GAAmBF,EAAgBN,EAAM,YAAY,MAAMM,IAAkB,SAAeD,EAAsBC,EAAgB,SAAS,MAAMD,IAAwB,OAArF,OAAmGA,EAAsB,QAAQ,EAA6B,OAAOI,GAA4CA,GAAM,OAAQ,GAAG,EAAE,IAAIA,GAAOA,EAAM,MAAM,QAAQ,EAAE,KAAK,GAAG,EAAQC,EAAUH,EAAY,MAAM,KAAK,EAAE,OAAOL,EAAS,CAAC,QAAQK,EAAY,cAAcG,CAAS,CAAC,CAAE,EAAE,CAACV,EAAM,QAAQ,CAAC,EAAsB,EAAKD,EAAU,CAAC,GAAGC,EAAM,SAAS,GAAG,KAAK,KAAKC,EAAM,cAAc,GAAG,YAAY,CAAC,CAAE,CAAE",
  "names": ["createStore", "state1", "dataStore", "Data", "setDataStore", "newState", "storeState", "storeSetters", "setStoreState", "setter", "useStore", "state", "setState", "ye", "ue", "useObserveData", "useStore", "createStore", "normalizeChildren", "children", "withReadTime", "Component", "props", "store", "setStore", "useStore", "ue", "_props_children_props", "_props_children", "textContent", "normalizeChildren", "child", "wordCount"]
}
