{"version":3,"file":"CMSGridLines.-QPrN4ii.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/VKN20AuriCyQaafom8Zg/IfMBSRbyezJwskJ4JXKI/CMSGridLines.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useLayoutEffect,useRef}from\"react\";export function withSmartCmsGrid(Component){return props=>{const gridRef=useRef(null);const overlayRef=useRef(null);const rafRef=useRef(null);const lastDrawnState=useRef(\"\");const OVERLAY_MARKER=\"smart-cms-grid-overlay\";// small epsilon for grouping edges\nconst EPS=1;const isLoaderTree=el=>{if(!el)return false;const name=el.getAttribute?.(\"data-framer-name\")?.toLowerCase()||\"\";// Filter out both \"loader\" and \"spinner\"\nif(name.includes(\"loader\")||name.includes(\"spinner\"))return true;const className=(el.className||\"\").toString().toLowerCase();if(className.includes(\"loader\")||className.includes(\"spinner\"))return true;const text=el.textContent?.trim().toLowerCase()||\"\";if(text===\"loader\"||text===\"spinner\")return true;for(const c of Array.from(el.children||[])){if(c instanceof HTMLElement&&isLoaderTree(c))return true;}return false;};const findCard=wrapper=>{const q=wrapper.querySelectorAll(\"[data-framer-name]\");for(const el of Array.from(q)){const name=el.getAttribute(\"data-framer-name\")?.toLowerCase()||\"\";if(name.includes(\"card\"))return el;}return wrapper;};const roundForDevice=v=>{// Round to physical pixels: prevents half-pixel jitter\nconst dpr=typeof window!==\"undefined\"&&window.devicePixelRatio||1;return Math.round(v*dpr)/dpr;};// Stable-measurement: returns { cols:number[], rows:number[] }\nconst measureGrid=grid=>{const wrappers=Array.from(grid.children).filter(el=>el instanceof HTMLElement&&!isLoaderTree(el)&&// Ignore our overlay\n    !el.hasAttribute(`data-${OVERLAY_MARKER}`));const gridRect=grid.getBoundingClientRect();const cards=wrappers.map(w=>{const c=findCard(w);const r=c.getBoundingClientRect();return{left:r.left-gridRect.left,right:r.right-gridRect.left,top:r.top-gridRect.top,bottom:r.bottom-gridRect.top};}).filter(b=>b.right>b.left&&b.bottom>b.top);if(!cards.length)return{cols:[],rows:[]};const cols=[];const rows=[];cards.forEach(b=>{if(!cols.some(x=>Math.abs(x-b.left)<EPS))cols.push(b.left);if(!cols.some(x=>Math.abs(x-b.right)<EPS))cols.push(b.right);if(!rows.some(y=>Math.abs(y-b.top)<EPS))rows.push(b.top);if(!rows.some(y=>Math.abs(y-b.bottom)<EPS))rows.push(b.bottom);});cols.sort((a,b)=>a-b);rows.sort((a,b)=>a-b);return{cols,rows};};const drawStable=(grid,cols,rows)=>{if(!overlayRef.current)return;const overlay=overlayRef.current;if(!cols.length||!rows.length)return;// Create state fingerprint to check if we actually need to redraw\nconst stateKey=`${cols.join(\",\")}_${rows.join(\",\")}`;if(lastDrawnState.current===stateKey){return;// Already drawn this exact state - don't clear or redraw\n}// NOW it's safe to clear since we know we're actually going to redraw\noverlay.innerHTML=\"\";lastDrawnState.current=stateKey;// Use outer bounds from measured columns/rows\nconst left=cols[0];const right=cols[cols.length-1];const top=rows[0];const bottom=rows[rows.length-1];const color=\"#D9D9D9\";const add=(x,y,w,h)=>{const el=document.createElement(\"div\");// Mark this element as part of the overlay\nel.setAttribute(`data-${OVERLAY_MARKER}`,\"true\");el.style.position=\"absolute\";el.style.left=`${roundForDevice(x)}px`;el.style.top=`${roundForDevice(y)}px`;el.style.width=`${Math.max(.5,w)}px`;el.style.height=`${Math.max(.5,h)}px`;el.style.background=color;el.style.pointerEvents=\"none\";overlay.appendChild(el);};// Determine which boundaries are shared (internal) vs edge (external)\n// Internal boundaries: not the first or last in the array\nconst internalCols=cols.slice(1,-1);const internalRows=rows.slice(1,-1);// Draw vertical lines\n// First column (left edge) - 1px\nadd(left,top,1,bottom-top);// Internal columns (shared boundaries) - 0.5px each\nfor(const x of internalCols){add(x,top,.5,bottom-top);}// Last column (right edge) - 1px\nadd(right,top,1,bottom-top);// Draw horizontal lines\n// First row (top edge) - 1px\nadd(left,top,right-left,1);// Internal rows (shared boundaries) - 0.5px each\nfor(const y of internalRows){add(left,y,right-left,.5);}// Last row (bottom edge) - 1px\nadd(left,bottom,right-left,1);console.log(`[SmartCmsGrid] Drew grid with ${cols.length} cols, ${rows.length} rows`);};// Draw only after measurement stabilizes across TWO consecutive RAF frames\nconst scheduleStableDraw=(grid,reason)=>{if(rafRef.current)cancelAnimationFrame(rafRef.current);console.log(`[SmartCmsGrid] Scheduling draw: ${reason||\"unknown\"}`);let prev={cols:[],rows:[]};let attempts=0;const maxAttempts=30;const step=()=>{attempts++;const cur=measureGrid(grid);// Check if we have actual content (not just empty grid)\nconst hasContent=cur.cols.length>0&&cur.rows.length>0;const colsSame=cur.cols.length===prev.cols.length&&cur.cols.every((v,i)=>Math.abs(v-prev.cols[i])<EPS);const rowsSame=cur.rows.length===prev.rows.length&&cur.rows.every((v,i)=>Math.abs(v-prev.rows[i])<EPS);if(colsSame&&rowsSame&&hasContent){// stable — commit draw\nconsole.log(`[SmartCmsGrid] Stable at attempt ${attempts}`);drawStable(grid,cur.cols.map(roundForDevice),cur.rows.map(roundForDevice));return;}// not stable yet -> keep trying but cap attempts\nprev=cur;if(attempts>=maxAttempts){// final attempt: draw whatever we have\nconsole.log(`[SmartCmsGrid] Max attempts reached, drawing final state`);if(hasContent){drawStable(grid,cur.cols.map(roundForDevice),cur.rows.map(roundForDevice));}return;}rafRef.current=requestAnimationFrame(step);};rafRef.current=requestAnimationFrame(step);};useLayoutEffect(()=>{const grid=gridRef.current;if(!grid)return;console.log(\"[SmartCmsGrid] Initializing...\");// Reset state on mount to ensure fresh draw\nlastDrawnState.current=\"\";// create overlay once and attach imperatively (safer for published builds)\nlet overlay=overlayRef.current;if(!overlay){overlay=document.createElement(\"div\");overlayRef.current=overlay;// Mark the overlay itself\noverlay.setAttribute(`data-${OVERLAY_MARKER}`,\"true\");// robust CSS - inset + absolute + high z-index so it sits above grid content\noverlay.style.position=\"absolute\";overlay.style.top=\"0\";overlay.style.left=\"0\";overlay.style.width=\"100%\";overlay.style.height=\"100%\";overlay.style.zIndex=\"9999\";overlay.style.pointerEvents=\"none\";// avoid creating a new stacking context by transforms; keep background transparent\noverlay.style.background=\"transparent\";overlay.style.boxSizing=\"border-box\";// Append to the grid element (as a last child). Imperative append prevents Framer from removing it in production.\ngrid.appendChild(overlay);}// Ensure grid is positioned so overlay absolute coordinates match\nconst prevGridPosition=grid.style.position;if(!prevGridPosition||prevGridPosition===\"static\"){grid.style.position=\"relative\";}// Observers\nconst ro=new ResizeObserver(()=>scheduleStableDraw(grid,\"resize\"));// Mutation observer that filters out our own overlay changes\nconst mo=new MutationObserver(mutations=>{// Filter out mutations from our overlay\nconst relevantMutations=mutations.filter(mut=>{// Check if the mutation target or any ancestor has our marker\nlet node=mut.target;while(node){if(node.hasAttribute&&node.hasAttribute(`data-${OVERLAY_MARKER}`)){return false// Skip this mutation\n;}if(node===grid)break;node=node.parentElement;}return true;});if(relevantMutations.length>0){console.log(`[SmartCmsGrid] Mutation detected: ${relevantMutations.length} changes`);scheduleStableDraw(grid,\"mutation\");}});// Intersection observer to detect when items become visible\nconst io=new IntersectionObserver(entries=>{const anyVisible=entries.some(e=>e.isIntersecting);if(anyVisible){console.log(\"[SmartCmsGrid] Items became visible\");scheduleStableDraw(grid,\"intersection\");}},{threshold:.01});// observe grid and immediate children (wrappers)\nro.observe(grid);Array.from(grid.children).forEach(c=>{if(c instanceof HTMLElement&&!isLoaderTree(c)&&!c.hasAttribute(`data-${OVERLAY_MARKER}`)){ro.observe(c);io.observe(c);}});// Watch for deeper changes including attributes\nmo.observe(grid,{childList:true,subtree:true,attributes:true,attributeFilter:[\"data-framer-name\",\"class\",\"style\"]});// Also redraw on window resize\nconst onResize=()=>scheduleStableDraw(grid,\"window-resize\");window.addEventListener(\"resize\",onResize);// CRITICAL: Continuous polling for CMS content\n// Many CMS systems load content after initial render\nlet pollCount=0;const maxPolls=30// Poll for 15 seconds\n;const pollInterval=setInterval(()=>{pollCount++;console.log(`[SmartCmsGrid] Poll ${pollCount}/${maxPolls}`);scheduleStableDraw(grid,`poll-${pollCount}`);if(pollCount>=maxPolls){clearInterval(pollInterval);}},500)// Check every 500ms\n;// initial draw (stabilized)\nscheduleStableDraw(grid,\"initial\");return()=>{console.log(\"[SmartCmsGrid] Cleaning up...\");ro.disconnect();mo.disconnect();io.disconnect();window.removeEventListener(\"resize\",onResize);clearInterval(pollInterval);if(rafRef.current)cancelAnimationFrame(rafRef.current);// cleanup overlay\nif(overlayRef.current&&overlayRef.current.parentElement===grid){overlayRef.current.remove();overlayRef.current=null;}// restore original grid position if we changed it (defensive)\nif(!prevGridPosition)grid.style.position=\"\";};},[]);// We return the component but DON'T include the overlay in JSX (we appended it imperatively)\nreturn /*#__PURE__*/_jsx(Component,{...props,ref:gridRef,children:props.children});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withSmartCmsGrid\":{\"type\":\"reactHoc\",\"name\":\"withSmartCmsGrid\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMSGridLines.map"],"mappings":"uIAAqF,SAAgB,EAAiB,EAAU,CAAC,MAAO,IAAO,CAAC,IAAM,EAAQA,EAAO,KAAK,CAAO,EAAWA,EAAO,KAAK,CAAO,EAAOA,EAAO,KAAK,CAAO,EAAeA,EAAO,GAAG,CAAO,EAAe,yBACtQ,EAAa,GAAI,CAAC,GAAG,CAAC,EAAG,MAAO,GAAM,IAAM,EAAK,EAAG,eAAe,mBAAmB,EAAE,aAAa,EAAE,GACzH,GAAG,EAAK,SAAS,SAAS,EAAE,EAAK,SAAS,UAAU,CAAC,MAAO,GAAK,IAAM,GAAW,EAAG,WAAW,IAAI,UAAU,CAAC,aAAa,CAAC,GAAG,EAAU,SAAS,SAAS,EAAE,EAAU,SAAS,UAAU,CAAC,MAAO,GAAK,IAAM,EAAK,EAAG,aAAa,MAAM,CAAC,aAAa,EAAE,GAAG,GAAG,IAAO,UAAU,IAAO,UAAU,MAAO,GAAK,IAAI,IAAM,KAAK,MAAM,KAAK,EAAG,UAAU,EAAE,CAAC,CA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