{"version":3,"file":"PrefetchGrid.Blt4CKCU.mjs","names":[],"sources":["https:/framerusercontent.com/modules/Tn63kgD8LFU6D3E0u2OH/LEnukLYQGP4tBtr39rbw/PrefetchGrid.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";/**\n * Code Override: withPrefetchGrid — applied to the project grid container.\n *\n * Two jobs, both deliberately cheap:\n *\n * 1. Warm every grid thumbnail once the page is idle. Framer already loads\n *    these eagerly (nothing is lazy), so this is normally a no-op that just\n *    guarantees the whole grid is in cache even if a thumbnail is added\n *    below the fold or Framer's loading behaviour changes.\n *\n * 2. Prefetch a project's page on tap/hover intent. This is the part that\n *    actually removes the blank moment after tapping a tile: pointerdown\n *    fires well before the navigation commits, so the document is already\n *    in flight by the time the tap completes.\n *\n * Deliberately NOT done: bulk-prefetching every project's full-size photo.\n * That is ~120KB x 32 and would cost more than it saves on a phone.\n *\n * Bails out entirely on Save-Data or a 2g-class connection.\n */const PREFETCHED=new Set;const MAX_PREFETCH=12;function onIdle(fn){if(typeof window===\"undefined\")return()=>{};const ric=window.requestIdleCallback;if(typeof ric===\"function\"){const id=ric(fn,{timeout:3e3});return()=>window.cancelIdleCallback?.(id);}const id=window.setTimeout(fn,1200);return()=>window.clearTimeout(id);}function shouldSkip(){const conn=navigator?.connection;if(!conn)return false;if(conn.saveData)return true;return/(^|-)2g$/.test(conn.effectiveType??\"\");}function prefetchDocument(href){if(PREFETCHED.has(href)||PREFETCHED.size>=MAX_PREFETCH)return;PREFETCHED.add(href);const link=document.createElement(\"link\");link.rel=\"prefetch\";link.as=\"document\";link.href=href;document.head.appendChild(link);}export function withPrefetchGrid(Component){function Wrapped(props){useEffect(()=>{if(typeof window===\"undefined\"||shouldSkip())return;// 1. Warm thumbnails once the page is quiet.\nconst cancelIdle=onIdle(()=>{for(const img of Array.from(document.images)){const url=img.currentSrc||img.src;if(!url||img.complete)continue;const warm=new Image;warm.decoding=\"async\";if(img.srcset)warm.srcset=img.srcset;if(img.sizes)warm.sizes=img.sizes;warm.src=url;}});// 2. Prefetch the project page on intent.\nconst onIntent=event=>{const target=event.target;const anchor=target?.closest?.('a[href*=\"/photo/\"], a[href*=\"/video/\"], a[href*=\"/shop/\"]');if(!anchor)return;const href=anchor.getAttribute(\"href\");if(!href||href===location.pathname)return;prefetchDocument(anchor.href);};document.addEventListener(\"pointerdown\",onIntent,{passive:true});document.addEventListener(\"pointerenter\",onIntent,{capture:true,passive:true});return()=>{cancelIdle();document.removeEventListener(\"pointerdown\",onIntent);document.removeEventListener(\"pointerenter\",onIntent,{capture:true});};},[]);return /*#__PURE__*/_jsx(Component,{...props});}return Wrapped;}\nexport const __FramerMetadata__ = {\"exports\":{\"withPrefetchGrid\":{\"type\":\"reactHoc\",\"name\":\"withPrefetchGrid\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PrefetchGrid.map"],"mappings":"uIAmBkD,SAAS,EAAO,EAAG,CAAC,GAAU,IAAS,OAAY,UAAU,CAAC,EAAE,IAAM,EAAI,EAAO,oBAAoB,GAAG,OAAO,GAAM,WAAW,CAAC,IAAM,EAAG,EAAI,EAAG,CAAC,QAAQ,GAAG,CAAC,EAAE,UAAU,EAAO,qBAAqB,CAAE,CAAE,CAAC,IAAM,EAAG,EAAO,WAAW,EAAG,IAAI,EAAE,UAAU,EAAO,aAAa,CAAE,CAAE,CAAC,SAAS,GAAY,CAAC,IAAM,EAAK,GAAW,WAA8D,OAA/C,EAAqB,EAAK,SAAgB,GAAW,WAAW,KAAK,EAAK,eAAe,EAAE,EAA/E,EAAiF,CAAC,SAAS,EAAiB,EAAK,CAAC,GAAG,EAAW,IAAI,CAAI,GAAG,EAAW,MAAM,EAAa,OAAO,EAAW,IAAI,CAAI,EAAE,IAAM,EAAK,SAAS,cAAc,MAAM,EAAE,EAAK,IAAI,WAAW,EAAK,GAAG,WAAW,EAAK,KAAK,EAAK,SAAS,KAAK,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