{"version":3,"file":"WithHidePastEvent.DFwsrwAp.mjs","names":["forwardRef","useRef","useState","useCallback","startTransition","useEffect","_jsx","__toCommonJS","ne","init_npm_react_18_3_1","te","window","ce","init_jsx_runtime","J","c","_e","de","init_ssg_sandbox_shims","init_framer_ChujFWHC","framer_ChujFWHC_exports","withHidePastEvent","Component","props","ref","rootRef","expired","setExpired","getLondonYYYYMMDD","parts","day","part","month","year","parseEventYYYYMMDD","value","trimmed","enGbMatch","enUsMatch","dayRaw","monthRaw","yearRaw","monthKey","monthNumber","monthMap","dayNumber","yearNumber","candidate","evaluateExpired","runtime","text","eventDate","londonToday","intervalId","observer","setRefs","node","init_WithHidePastEvent","__esmMin"],"sources":["https:/framerusercontent.com/modules/5uCULpBwc8D9AE2Oqi1p/z8qxjZMJV508q72gUfWj/WithHidePastEvent.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,startTransition,useCallback,useEffect,useRef,useState}from\"react\";const monthMap={jan:1,january:1,feb:2,february:2,mar:3,march:3,apr:4,april:4,may:5,jun:6,june:6,jul:7,july:7,aug:8,august:8,sep:9,sept:9,september:9,oct:10,october:10,nov:11,november:11,dec:12,december:12};/*\nUser request:\nCreate code override withHidePastEvent on EXISTING native event card frame, not component.\nCard first child Calendar Date Header contains CMS-bound date text formatted en-GB medium e.g. 8 Nov 2026.\nNeed automatic browser clock hiding after event day ends Europe/London, preserve CMS and canvas structure.\nUse forwarded ref root DOM, effect reads first child's textContent parses explicit English month abbreviations/day/year\n(not unreliable Date.parse); compare date YYYYMMDD to current London date via Intl.DateTimeFormat formatToParts.\nset React expired state and merge style display:none when expired so grid collapses, recheck minute interval and\nMutationObserver text changes, cleanup. Invalid missing dates remain visible. Canvas RenderTarget.canvas should keep\ncards visible for editing. SSR stable initially visible. No fetch. Standard export return ComponentType for override\ndetection. Document that this hides listing only not unpublishes event detail URL.\n*/export function withHidePastEvent(Component){return /*#__PURE__*/forwardRef(function WithHidePastEvent(props,ref){const rootRef=useRef(null);const[expired,setExpired]=useState(false);const getLondonYYYYMMDD=useCallback(()=>{try{const formatter=new Intl.DateTimeFormat(\"en-GB\",{timeZone:\"Europe/London\",day:\"2-digit\",month:\"2-digit\",year:\"numeric\"});const parts=formatter.formatToParts(new Date);const day=parts.find(part=>part.type===\"day\")?.value;const month=parts.find(part=>part.type===\"month\")?.value;const year=parts.find(part=>part.type===\"year\")?.value;if(!day||!month||!year)return null;return`${year}${month}${day}`;}catch{return null;}},[]);const parseEventYYYYMMDD=useCallback(value=>{const trimmed=value.trim().replace(/^[A-Za-z]+,\\s*/,\"\")// strip weekday prefix\n;const enGbMatch=/^(\\d{1,2})\\s+([A-Za-z.]+)\\s+(\\d{4})$/.exec(trimmed);const enUsMatch=/^([A-Za-z.]+)\\s+(\\d{1,2}),\\s*(\\d{4})$/.exec(trimmed);let dayRaw=\"\";let monthRaw=\"\";let yearRaw=\"\";if(enGbMatch){dayRaw=enGbMatch[1];monthRaw=enGbMatch[2];yearRaw=enGbMatch[3];}else if(enUsMatch){monthRaw=enUsMatch[1];dayRaw=enUsMatch[2];yearRaw=enUsMatch[3];}else{return null;}const monthKey=monthRaw.toLowerCase().replace(/\\./g,\"\");const monthNumber=monthMap[monthKey];if(!monthNumber)return null;const dayNumber=Number(dayRaw);const yearNumber=Number(yearRaw);if(!Number.isInteger(dayNumber)||!Number.isInteger(yearNumber)||yearNumber<1e3||yearNumber>9999){return null;}const candidate=new Date(Date.UTC(yearNumber,monthNumber-1,dayNumber));const isValidDate=candidate.getUTCFullYear()===yearNumber&&candidate.getUTCMonth()===monthNumber-1&&candidate.getUTCDate()===dayNumber;if(!isValidDate)return null;const day=String(dayNumber).padStart(2,\"0\");const month=String(monthNumber).padStart(2,\"0\");const year=String(yearNumber);return`${year}${month}${day}`;},[]);const evaluateExpired=useCallback(()=>{if(typeof window===\"undefined\")return;// Keep expired entries visible while editing in the Framer canvas.\ntry{const runtime=require(\"framer\");if(runtime.RenderTarget?.current()===runtime.RenderTarget.canvas){startTransition(()=>setExpired(false));return;}}catch{}const root=rootRef.current;const firstChild=root?.firstElementChild;const text=firstChild?.textContent??\"\";const eventDate=parseEventYYYYMMDD(text);const londonToday=getLondonYYYYMMDD();if(!eventDate||!londonToday){startTransition(()=>setExpired(false));return;}startTransition(()=>setExpired(eventDate<londonToday));},[getLondonYYYYMMDD,parseEventYYYYMMDD]);useEffect(()=>{if(typeof window===\"undefined\")return;evaluateExpired();const intervalId=window.setInterval(()=>{evaluateExpired();},6e4);const observer=new MutationObserver(()=>{evaluateExpired();});if(rootRef.current?.firstElementChild){observer.observe(rootRef.current.firstElementChild,{childList:true,characterData:true,subtree:true});}return()=>{window.clearInterval(intervalId);observer.disconnect();};},[evaluateExpired]);const setRefs=useCallback(node=>{rootRef.current=node;if(typeof ref===\"function\"){ref(node);}else if(ref&&typeof ref===\"object\"){ref.current=node;}},[ref]);return /*#__PURE__*/_jsx(Component,{...props,ref:setRefs,style:{...props.style,display:expired?\"none\":props.style?.display}});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withHidePastEvent\":{\"type\":\"reactHoc\",\"name\":\"withHidePastEvent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./WithHidePastEvent.map"],"mappings":"A,sNAWE,SAAgBqB,EAAkBC,EAAU,CAAC,MAAoBtB,gBAAW,SAA2BuB,EAAMC,EAAI,CAAC,IAAMC,EAAQxB,EAAO,IAAI,EAAO,CAACyB,EAAQC,GAAYzB,EAAS,EAAK,EAAQ0B,EAAkBzB,MAAgB,CAAC,GAAG,CAA0H,IAAM0B,EAAM,IAAjH,KAAK,eAAe,QAAQ,CAAC,SAAS,gBAAgB,IAAI,UAAU,MAAM,UAAU,KAAK,SAAS,CAAuB,CAAC,CAAC,8BAAc,IAAI,IAAI,EAAQC,EAAID,EAAM,KAAKE,GAAMA,EAAK,OAAO,KAAK,CAAC,EAAE,MAAYC,EAAMH,EAAM,KAAKE,GAA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