{"version":3,"file":"TopicLinks.DF0MlELF.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/n7QglVLcfZhmiR3iRKGd/g9WkjPaAZboEFlQtdmkZ/TopicLinks.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect,useRef}from\"react\";/**\n * Atrium topic links. Framer's link field can't take an address with a ?,\n * so link the button to the Contact page as usual and give it one of these:\n *\n * withValuationTopic  the Contact page opens on Value my home\n * withQuestionTopic   the Contact page opens on Ask a question\n * withViewingTopic    the Contact page opens on Book a viewing\n *\n * Put it on the button itself, or on a stack around it when the button\n * already has an override (such as withMagnet). Every link inside that\n * leads to another page of the site gets the topic.\n */export function withValuationTopic(Component){return topicLink(Component,\"valuation\");}export function withQuestionTopic(Component){return topicLink(Component,\"question\");}export function withViewingTopic(Component){return topicLink(Component,\"viewing\");}const clean=path=>String(path??\"\").replace(/\\/+$/,\"\").toLowerCase();// A link that leads to another page of this site\nconst isPageLink=a=>{try{const u=new URL(a.getAttribute(\"href\"),location.href);return u.origin===location.origin&&clean(u.pathname)!==clean(location.pathname);}catch{return false;}};function topicLink(Component,topic){return /*#__PURE__*/forwardRef((props,ref)=>{const own=useRef(null);useEffect(()=>{const box=own.current;if(!box)return;const links=()=>[box,...box.querySelectorAll(\"a[href]\")].filter(a=>a.matches(\"a[href]\")&&isPageLink(a));const address=a=>{const u=new URL(a.getAttribute(\"href\"),location.href);u.hash=\"\";u.searchParams.set(\"topic\",topic);return u.pathname+u.search;};const update=()=>links().forEach(a=>a.setAttribute(\"href\",address(a)));// Framer would open the page without the ?topic, so this link opens it instead.\n// A new-tab click keeps the browser's own handling, with the address already updated\nconst click=e=>{const a=e.target.closest?.(\"a[href]\");if(!a||!box.contains(a)||!isPageLink(a))return;update();if(e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;e.preventDefault();e.stopPropagation();location.assign(address(a));};update();box.addEventListener(\"pointerover\",update);box.addEventListener(\"focusin\",update);box.addEventListener(\"click\",click,true);return()=>{box.removeEventListener(\"pointerover\",update);box.removeEventListener(\"focusin\",update);box.removeEventListener(\"click\",click,true);};},[]);const setRef=el=>{own.current=el;if(typeof ref===\"function\")ref(el);else if(ref)ref.current=el;};return /*#__PURE__*/_jsx(Component,{ref:setRef,...props});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withQuestionTopic\":{\"type\":\"reactHoc\",\"name\":\"withQuestionTopic\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withValuationTopic\":{\"type\":\"reactHoc\",\"name\":\"withValuationTopic\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withViewingTopic\":{\"type\":\"reactHoc\",\"name\":\"withViewingTopic\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TopicLinks.map"],"mappings":"gIAWG,SAAgB,EAAmB,EAAU,CAAC,OAAO,EAAU,EAAU,WAAW,CAAE,CAAC,SAAgB,EAAkB,EAAU,CAAC,OAAO,EAAU,EAAU,UAAU,CAAE,CAAC,SAAgB,EAAiB,EAAU,CAAC,OAAO,EAAU,EAAU,SAAS,CAAE,CAC3E,SAAS,EAAU,EAAU,EAAM,CAAC,OAAoB,GAAY,EAAM,IAAM,CAAC,IAAM,EAAIA,EAAO,IAAI,EAEsV,OAFpV,MAAc,CAAC,IAAM,EAAI,EAAI,QAAQ,GAAG,CAAC,EAAI,OAAO,IAAM,MAAU,CAAC,EAAI,GAAG,EAAI,iBAAiB,SAAS,CAAC,CAAC,CAAC,OAAO,GAAG,EAAE,QAAQ,SAAS,GAAG,EAAW,CAAC,CAAC,EAAQ,EAAQ,GAAG,CAAC,IAAM,EAAE,IAAI,IAAI,EAAE,aAAa,MAAM,EAAE,SAAS,IAAI,EAA8C,MAA5C,GAAE,KAAK,GAAG,EAAE,aAAa,IAAI,QAAQ,CAAK,EAAS,EAAE,SAAS,EAAE,MAAO,EAAQ,MAAW,EAAM,CAAC,CAAC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