{"version":3,"file":"TrackerCount.lfGA8mn5.mjs","names":["useRef","__esmMin","init_npm_react_18_3_1","window","de","init_jsx_runtime","J","c","ce","init_ssg_sandbox_shims","withTrackerCount","wrapRef","cancelled","findTextNode","root","walker","PLACEHOLDER","getCount","src","best","el","lastCount","stableTicks","attempts","poll","textNode","count","Component","props","init_TrackerCount"],"sources":["https:/framerusercontent.com/modules/hDuy66G9jJhgbX0gsOUJ/ig2ED6D13zl6BRPywwm7/TrackerCount.js"],"sourcesContent":["// CMS count for hero text.\n// Replaces a \"[xxxx]\" placeholder in the wrapped layer's text with the\n// number of items in a CMS collection. Displays the final number directly\n// (no count-up animation).\n//\n// Setup (per page):\n// 1. Add a hidden frame whose name ENDS WITH \"Count-Source\"\n//    (e.g. \"Tracker-Count-Source\", \"News-Count-Source\"):\n//    1x1-4px, opacity 0.01, position absolute. Inside it, a Collection List\n//    bound to the collection you want counted — NO limit, no filters, with\n//    a tiny empty frame as the repeated item.\n// 2. Apply withTrackerCount to the hero instance (or any layer containing\n//    the \"[xxxx]\" placeholder text) on that page.\n//\n// The override counts the repeated elements in the page's Count-Source and\n// writes the total into the placeholder.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect,useRef}from\"react\";const PLACEHOLDER=/\\[x+\\]/i// matches [xxxx], [xxx], etc.\n;export function withTrackerCount(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const wrapRef=useRef(null);useEffect(()=>{if(typeof window===\"undefined\")return;let cancelled=false;// Find the text node containing the placeholder inside the hero\nconst findTextNode=()=>{const root=wrapRef.current;if(!root)return null;const walker=document.createTreeWalker(root,NodeFilter.SHOW_TEXT);let n;while(n=walker.nextNode()){if(PLACEHOLDER.test(n.textContent||\"\"))return n;}return null;};// Count items inside the page's hidden source list. Any frame\n// whose name ends with \"Count-Source\" qualifies.\nconst getCount=()=>{const src=document.querySelector('[data-framer-name$=\"Count-Source\"]');if(!src)return-1;let best=0;src.querySelectorAll(\"*\").forEach(el=>{if(el.children.length>best)best=el.children.length;});return best;};// Wait for both the text node and a stable count, then write it in\nlet lastCount=-1;let stableTicks=0;let attempts=0;const poll=()=>{if(cancelled)return;const textNode=findTextNode();const count=getCount();if(textNode&&count>=0){if(count===lastCount)stableTicks++;else stableTicks=0;lastCount=count;if(stableTicks>=2){textNode.textContent=(textNode.textContent||\"\").replace(PLACEHOLDER,count.toLocaleString());return;}}if(++attempts<40)setTimeout(poll,150)// up to ~6s\n;};poll();return()=>{cancelled=true;};},[]);return /*#__PURE__*/_jsx(\"div\",{ref:wrapRef,style:{display:\"contents\"},children:/*#__PURE__*/_jsx(Component,{ref:ref,...props})});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withTrackerCount\":{\"type\":\"reactHoc\",\"name\":\"withTrackerCount\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TrackerCount.map"],"mappings":"A,8IAiBC,SAAgBU,EAAiB,EAAU,CAAC,MAAoB,iBAAY,EAAM,IAAM,CAAC,IAAMC,EAAQX,EAAO,IAAI,EAKvE,OALyEQ,MAAc,CAAC,GAAUL,IAAS,OAAY,OAAO,IAAIS,EAAU,GAClLC,MAAiB,CAAC,IAAMC,EAAKH,EAAQ,QAAQ,GAAG,CAACG,EAAK,OAAO,KAAK,IAAMC,EAAO,SAAS,iBAAiBD,EAAK,WAAW,SAAS,EAAM,EAAE,KAAM,EAAEC,EAAO,SAAS,GAAG,GAAGC,EAAY,KAAK,EAAE,aAAa,EAAE,EAAE,OAAO,EAAG,OAAO,IAAK,EAElOC,MAAa,CAAC,IAAMC,EAAI,SAAS,cAAc,oCAAoC,EAAE,GAAG,CAACA,EAAI,MAAM,GAAG,IAAIC,EAAK,EAA+F,OAA7FD,EAAI,iBAAiB,GAAG,CAAC,CAAC,QAAQ,GAAI,CAAIE,EAAG,SAAS,OAAOD,IAAK,EAAKC,EAAG,SAAS,OAAO,CAAC,EAASD,CAAK,EAC5NE,EAAU,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