{"version":3,"file":"BlogHelpers.BPCb9cJR.mjs","names":["useState","blogContent","__legacyOverrideHOC_DataObserverContext","_jsx"],"sources":["https:/framerusercontent.com/modules/rW8YoV64sTcSTVvIJWd5/izCgZNvFsM2Izr8F3sVe/BlogHelpers.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";import{Data}from\"framer\";import{useState}from\"react\";// ADD CLASS NAME TO OBJECT\nexport function withClass(Component){return props=>{props.className+=\" blog-tag\"// Remember to add a space\n;return /*#__PURE__*/_jsx(Component,{...props});};}// CHANGE COMPONENT VARIANT BASED ON URL PARAMETER\n// Create a Data object to store the current variant\nconst store=Data({currentVariant:\"default\"});// Function to update the variant based on URL\nfunction updateVariantFromURL(){const urlParams=new URLSearchParams(window.location.search);const urlVariant=urlParams.get(\"variant\");if(urlVariant){store.currentVariant=urlVariant;}}// Call this function when the component mounts\nif(typeof window!==\"undefined\"){updateVariantFromURL();// Optional: Listen for URL changes\nwindow.addEventListener(\"popstate\",updateVariantFromURL);}export function VariantOverride(){return{variant:store.currentVariant};}// APPEND URL PARAMETER TO LINK BASED ON TAG SLUG PROP\nexport function AppendUrlParameter(props){return{onTap(event){// Prevent the default link navigation\nevent.preventDefault();// Define the target link (e.g., from a component or hardcoded)\nconst targetLink=\"https://www.carbon-direct.com/insights\";// Define the parameter key\nconst paramKey=\"variant\";// Get the slug value from props\nconst paramValue=props.slug||\"view-all\"// Fallback to a default value\n;const anchor=\"#feed\";// Create a new URL object\nconst newUrl=new URL(targetLink);// Append or update the parameter\nnewUrl.searchParams.set(paramKey,paramValue);newUrl.hash=anchor;// Navigate to the new URL\nwindow.location.href=newUrl.toString();}};}export function ScrollToAnchor(){return{onLoad:()=>{setTimeout(()=>{if(window.location.hash){const target=document.querySelector(window.location.hash);if(target){target.scrollIntoView({behavior:\"smooth\",block:\"start\"});}}},100)// Small delay to ensure elements are rendered\n;}};}// REMOVE PARAMETER TO CURRENT URL ON CLICK\nexport function RemoveParameter(){return{onTap:()=>{const url=new URL(window.location.href);url.searchParams.delete(\"variant\");window.history.replaceState({},\"\",url.toString());}};}// HIDE SIDE NAV IF THERE AREN'T ANY H2S OR H3S IN THE BLOG CONTENT\nexport function HideIfNoHeadings(){const[isVisible,setIsVisible]=useState(true);useEffect(()=>{const checkHeadings=()=>{const blogContent=document.querySelector(\"#blog-content\");if(blogContent){const hasHeadings=blogContent.querySelectorAll(\"h2, h3\").length>0;setIsVisible(hasHeadings);}else{setIsVisible(false);}};// Run on mount\ncheckHeadings();// Set up observer\nconst observer=new MutationObserver(()=>{checkHeadings();});const blogContent=document.querySelector(\"#blog-content\");if(blogContent){observer.observe(blogContent,{childList:true,subtree:true});}return()=>observer.disconnect();},[]);return{style:{display:isVisible?\"block\":\"none\"}};}// FIX FILTERING ON MOBILE\nexport function FixDropdown(){return{onPointerDown:event=>{event.preventDefault()// Prevents focus conflicts\n;event.stopPropagation()// Prevents event bubbling issues\n;const dropdownMenu=document.querySelector(\".framer-a4IS0\");if(dropdownMenu){dropdownMenu.classList.toggle(\"open\");}},onFocus:event=>{event.preventDefault()// Prevents focus-based triggering\n;}};}import{useContext as __legacyOverrideHOC_useContext}from\"react\";import{DataObserverContext as __legacyOverrideHOC_DataObserverContext}from\"framer\";export function withVariantOverride(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...VariantOverride(props)});};}withVariantOverride.displayName=\"VariantOverride\";export function withAppendUrlParameter(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...AppendUrlParameter(props)});};}withAppendUrlParameter.displayName=\"AppendUrlParameter\";export function withScrollToAnchor(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...ScrollToAnchor(props)});};}withScrollToAnchor.displayName=\"ScrollToAnchor\";export function withRemoveParameter(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...RemoveParameter(props)});};}withRemoveParameter.displayName=\"RemoveParameter\";export function withHideIfNoHeadings(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...HideIfNoHeadings(props)});};}withHideIfNoHeadings.displayName=\"HideIfNoHeadings\";export function withFixDropdown(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...FixDropdown(props)});};}withFixDropdown.displayName=\"FixDropdown\";\nexport const __FramerMetadata__ = {\"exports\":{\"FixDropdown\":{\"type\":\"override\",\"name\":\"FixDropdown\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withHideIfNoHeadings\":{\"type\":\"reactHoc\",\"name\":\"withHideIfNoHeadings\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFixDropdown\":{\"type\":\"reactHoc\",\"name\":\"withFixDropdown\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAppendUrlParameter\":{\"type\":\"reactHoc\",\"name\":\"withAppendUrlParameter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withScrollToAnchor\":{\"type\":\"reactHoc\",\"name\":\"withScrollToAnchor\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"AppendUrlParameter\":{\"type\":\"override\",\"name\":\"AppendUrlParameter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"ScrollToAnchor\":{\"type\":\"override\",\"name\":\"ScrollToAnchor\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"HideIfNoHeadings\":{\"type\":\"override\",\"name\":\"HideIfNoHeadings\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withVariantOverride\":{\"type\":\"reactHoc\",\"name\":\"withVariantOverride\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRemoveParameter\":{\"type\":\"reactHoc\",\"name\":\"withRemoveParameter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"RemoveParameter\":{\"type\":\"override\",\"name\":\"RemoveParameter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withClass\":{\"type\":\"reactHoc\",\"name\":\"withClass\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"VariantOverride\":{\"type\":\"override\",\"name\":\"VariantOverride\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BlogHelpers.map"],"mappings":"uMACA,SAAgB,EAAU,EAAU,CAAC,MAAO,KAAQ,EAAM,WAAW,YAChD,EAAK,EAAU,CAAC,GAAG,EAAM,CAAC,EAG/C,SAAS,GAAsB,CAA6D,IAAM,EAAlD,IAAI,gBAAgB,EAAO,SAAS,OAAO,CAA4B,IAAI,UAAU,CAAI,IAAY,EAAM,eAAe,GAEhH,SAAgB,GAAiB,CAAC,MAAM,CAAC,QAAQ,EAAM,eAAe,CAChI,SAAgB,EAAmB,EAAM,CAAC,MAAM,CAAC,MAAM,EAAM,CAC7D,EAAM,gBAAgB,CACtB,IAEM,EAAW,EAAM,MAAM,WAEvB,EAAO,IAAI,IAAI,yCAAW,CAChC,EAAO,aAAa,IAAI,UAAS,EAAW,CAAC,EAAO,KAAK,QACzD,EAAO,SAAS,KAAK,EAAO,UAAU,EAAG,CAAE,SAAgB,GAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,GAAG,EAAO,SAAS,KAAK,CAAC,IAAM,EAAO,SAAS,cAAc,EAAO,SAAS,KAAK,CAAI,GAAQ,EAAO,eAAe,CAAC,SAAS,SAAS,MAAM,QAAQ,CAAC,GAAK,IAAI,EAC3Q,CACH,SAAgB,GAAiB,CAAC,MAAM,CAAC,UAAU,CAAC,IAAM,EAAI,IAAI,IAAI,EAAO,SAAS,KAAK,CAAC,EAAI,aAAa,OAAO,UAAU,CAAC,EAAO,QAAQ,aAAa,EAAE,CAAC,GAAG,EAAI,UAAU,CAAC,EAAG,CACnL,SAAgB,GAAkB,CAAC,GAAK,CAAC,EAAU,GAAcA,EAAS,GAA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