{"version":3,"file":"PhaseOneRuntimeCleanup.COC2XN0a.mjs","names":[],"sources":["https:/framerusercontent.com/modules/2GpC6yvtJqcvS2AFjQgi/kMdkLvN24oyVqv4IIIbM/PhaseOneRuntimeCleanup.js"],"sourcesContent":["/**\n * Create a new Framer code override file named PhaseOneRuntimeCleanup.tsx. Export exactly one code override: withPhaseOneRuntimeCleanup(Component). It must return the supplied Component unchanged apart from lifecycle behavior; no wrappers, no UI, no click handlers, no preventDefault, analytics, cookies, external dependencies, or visual/style changes.\n * In a React useEffect with SSR guards, implement idempotent patchRuntime() against document:\n * 1) About card anchors: only when an anchor href is empty/null (missing attr, blank, '#', or resolved empty), normalize anchor visible text whitespace, then if it starts exactly with respectively:\n * - 'Security Professional security services' set href https://www.myinvincible.co.uk/services/security\n * - 'Construction Property maintenance' set href https://www.myinvincible.co.uk/services/construction\n * - 'Waste Waste collection' set href https://www.myinvincible.co.uk/services/waste\n * 2) Remove redundant generated anchors whose normalized visible text is exactly 'Phone Link Text' or 'Email Link Text'.\n * 3) Form accessibility attributes for Name/Email/Message.\n * 4) Image accessibility: set missing alt based on nearby context where appropriate, otherwise empty alt for decorative/generated assets.\n * 5) Logo accessibility: anchors with normalized text exactly 'INVINCIBLE' get aria-label='Invincible home'.\n * Lifecycle: run patchRuntime immediately, in requestAnimationFrame, and after short timeout, plus MutationObserver on document.body with proper cleanup.\n */import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect}from\"react\";export function withPhaseOneRuntimeCleanup(Component){return /*#__PURE__*/forwardRef(function WithPhaseOneRuntimeCleanup(props,ref){useEffect(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;if(!document.body)return;const normalizeText=value=>(value??\"\").replace(/\\s+/g,\" \").trim();const setAttributeIfDifferent=(element,attribute,value)=>{if(!element)return;if(element.getAttribute(attribute)!==value){element.setAttribute(attribute,value);}};const textStartsWithMap=[{prefix:\"Security Professional security services\",href:\"https://www.myinvincible.co.uk/services/security\"},{prefix:\"Construction Property maintenance\",href:\"https://www.myinvincible.co.uk/services/construction\"},{prefix:\"Waste Waste collection\",href:\"https://www.myinvincible.co.uk/services/waste\"}];const applyImageAlt=img=>{if(img.hasAttribute(\"alt\"))return;const src=normalizeText(img.getAttribute(\"src\")).toLowerCase();const className=normalizeText(img.getAttribute(\"class\")).toLowerCase();const isDecorative=/gradient|texture|overlay|background|fill|noise|pattern|placeholder|blur|mask|backdrop|responsive/.test(src)||/gradient|texture|overlay|background|fill|noise|pattern|placeholder|blur|mask|backdrop|responsive/.test(className);let contextText=\"\";let current=img;let depth=0;while(current&&depth<6){const maybeContainer=current.closest(\"a, section, article, [role='region'], [data-framer-name], div\");if(!maybeContainer)break;const text=normalizeText(maybeContainer.textContent);if(text.length>0){contextText=text;break;}current=maybeContainer.parentElement;depth+=1;}const normalizedContext=contextText.toLowerCase();if(isDecorative){img.setAttribute(\"alt\",\"\");return;}if(normalizedContext.includes(\"security\")){img.setAttribute(\"alt\",\"Invincible security professional\");return;}if(normalizedContext.includes(\"fire safety\")||normalizedContext.includes(\"compliance\")){img.setAttribute(\"alt\",\"Fire exit sign\");return;}if(normalizedContext.includes(\"construction\")){img.setAttribute(\"alt\",\"Invincible construction operative\");return;}if(normalizedContext.includes(\"waste\")){img.setAttribute(\"alt\",\"Invincible waste operative\");return;}img.setAttribute(\"alt\",\"\");};const patchRuntime=()=>{const anchors=Array.from(document.querySelectorAll(\"a\"));for(const anchor of anchors){const normalizedText=normalizeText(anchor.textContent);const rawHref=anchor.getAttribute(\"href\");const trimmedHref=normalizeText(rawHref);const hasResolvedEmpty=rawHref==null&&normalizeText(anchor.href)===normalizeText(window.location.href);const isEmptyHref=rawHref==null||trimmedHref===\"\"||trimmedHref===\"#\"||hasResolvedEmpty;if(isEmptyHref){for(const item of textStartsWithMap){if(normalizedText.startsWith(item.prefix)){setAttributeIfDifferent(anchor,\"href\",item.href);break;}}}if(normalizedText===\"Phone Link Text\"||normalizedText===\"Email Link Text\"){anchor.remove();continue;}if(normalizedText===\"INVINCIBLE\"){setAttributeIfDifferent(anchor,\"aria-label\",\"Invincible home\");}}const nameInput=document.querySelector('input[name=\"Name\"]');const emailInput=document.querySelector('input[name=\"Email\"]');const messageTextarea=document.querySelector('textarea[name=\"Message\"]');const messageFallback=document.querySelector('[name=\"Message\"]');const messageControl=messageTextarea??messageFallback;setAttributeIfDifferent(nameInput,\"aria-label\",\"Full name\");setAttributeIfDifferent(nameInput,\"autocomplete\",\"name\");setAttributeIfDifferent(emailInput,\"aria-label\",\"Work email address\");setAttributeIfDifferent(emailInput,\"autocomplete\",\"email\");setAttributeIfDifferent(messageControl,\"aria-label\",\"Service, site location and timing\");const images=Array.from(document.querySelectorAll(\"img\"));for(const image of images){applyImageAlt(image);}};patchRuntime();const frameId=window.requestAnimationFrame(()=>patchRuntime());const timerId=window.setTimeout(()=>patchRuntime(),60);const observer=new MutationObserver(()=>patchRuntime());observer.observe(document.body,{childList:true,subtree:true,attributes:true});return()=>{observer.disconnect();window.cancelAnimationFrame(frameId);window.clearTimeout(timerId);};},[]);return /*#__PURE__*/_jsx(Component,{...props,ref:ref});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withPhaseOneRuntimeCleanup\":{\"type\":\"reactHoc\",\"name\":\"withPhaseOneRuntimeCleanup\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PhaseOneRuntimeCleanup.map"],"mappings":"uIAYsF,SAAgB,EAA2B,EAAU,CAAC,OAAoB,EAAW,SAAoC,EAAM,EAAI,CAAy3H,OAAx3H,MAAc,CAAsE,GAA3D,IAAS,QAAa,OAAO,SAAW,KAAsB,CAAC,SAAS,KAAK,OAAO,IAAM,EAAc,IAAQ,GAAO,GAAA,CAAI,QAAQ,OAAO,GAAG,CAAC,CAAC,KAAK,EAAQ,GAAyB,EAAQ,EAAU,IAAQ,CAAK,GAAkB,EAAQ,aAAa,CAAS,IAAI,GAAO,EAAQ,aAAa,E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