{"version":3,"file":"HideCurrentArticle.D2D2kLOm.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/qLtxNhQn6xQmmkEU1mvF/aN7fyvV4ywBkWsbKtuBn/HideCurrentArticle.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";/**\n * Hides a CMS list item when its link matches the current page URL.\n *\n * Apply this override on the Link (or the card component) inside the\n * Collection List in the \"Other News\" section of /resources/news/:slug.\n *\n * Strategy:\n * 1. Try to read the link from props (fast path).\n * 2. If that fails, inspect the rendered DOM for an <a href> and\n *    compare it to window.location.pathname.\n *\n * Tip: bump the CMS Collection List \"Max Items\" by +1 so you still get\n * the desired number of suggestions after one is filtered out.\n */export function hideIfCurrentArticle(Component){return props=>{const wrapperRef=useRef(null);const[hidden,setHidden]=useState(false);// Fast path: check props synchronously (avoids a flash)\nconst propsLink=(()=>{const candidate=(typeof props?.link===\"string\"?props.link:props?.link&&typeof props.link===\"object\"?props.link.href||props.link.url:null)||props?.href||props?.url||null;return typeof candidate===\"string\"?candidate:null;})();const initialMatch=typeof window!==\"undefined\"&&propsLink&&samePath(propsLink,window.location.pathname);useEffect(()=>{if(typeof window===\"undefined\")return;if(initialMatch){setHidden(true);return;}// Fallback: inspect the rendered DOM\nconst el=wrapperRef.current;if(!el)return;const anchor=el.tagName===\"A\"?el:el.querySelector(\"a\");if(!anchor||!anchor.getAttribute(\"href\"))return;try{const url=new URL(anchor.href,window.location.origin);if(samePath(url.pathname,window.location.pathname)){setHidden(true);}}catch{// ignore malformed URLs\n}},[initialMatch]);if(hidden)return null;return /*#__PURE__*/_jsx(\"div\",{ref:wrapperRef,style:{display:\"contents\"},children:/*#__PURE__*/_jsx(Component,{...props})});};}function samePath(a,b){const norm=s=>s.split(\"?\")[0].split(\"#\")[0].replace(/\\/+$/,\"\").toLowerCase();return norm(a)===norm(b);}\nexport const __FramerMetadata__ = {\"exports\":{\"hideIfCurrentArticle\":{\"type\":\"react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