{"version":3,"file":"BookHover.BkhB04mN.mjs","names":["useState","useRef","__esmMin","window","init_npm_react_18_3_1","init_ssg_sandbox_shims","ce","init_jsx_runtime","J","p","_e","de","useMotionValue","useSpring","init_framer_motion_DhsWWWsN","ensureKeyframes","KF_LOOP","el","KF_ONCE","hoverDevice","reducedMotion","Shine","strength","makeOverride","Wrapped","rest","props","canHover","setCanHover","motionOk","setMotionOk","hovered","setHovered","shineKey","setShineKey","rx","ry","sc","rotateX","SPRING","rotateY","scale","ok","handleEnter","onMouseEnter","k","opts","HOVER_SCALE","handleMove","onMouseMove","r","px","py","MAX_TILT_Y","MAX_TILT_X","handleLeave","onMouseLeave","motionStyle","PERSPECTIVE","Component","style","children","name","withBookHover","withPhotoShine","withCardShines","hostRef","root","cleanups","attach","wrap","img","card","layer","band","play","mo","fn","init_BookHover"],"sources":["https:/framerusercontent.com/modules/rT5O6YB1gm8cWdA30yhw/2z01OYnIvLzS6Wuba1Oj/BookHover.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{forwardRef,useEffect,useRef,useState}from\"react\";import{useMotionValue,useSpring}from\"framer-motion\";// Tuning\nconst MAX_TILT_Y=5// deg, left/right\n;const MAX_TILT_X=3.5// deg, up/down\n;const HOVER_SCALE=1.015;const PERSPECTIVE=1300;const SPRING={stiffness:120,damping:20,mass:.6};const LOOP_SECONDS=2.5// photo shine: one sweep, then rests until the next loop\n;const KF_ONCE=\"book-card-shine\";const KF_LOOP=\"book-card-shine-loop\";function ensureKeyframes(){if(typeof document===\"undefined\")return;if(document.getElementById(KF_LOOP))return;const el=document.createElement(\"style\");el.id=KF_LOOP;el.textContent=\"@keyframes \"+KF_ONCE+\" { 0% { transform: translate(-60%, -60%); opacity: 0 } 20% { opacity: 1 } 80% { opacity: 1 } 100% { transform: translate(60%, 60%); opacity: 0 } }\"+\"@keyframes \"+KF_LOOP+\" { 0% { transform: translate(-60%, -60%); opacity: 0 } 6% { opacity: 1 } 26% { opacity: 1 } 32% { transform: translate(60%, 60%); opacity: 0 } 100% { transform: translate(60%, 60%); opacity: 0 } }\";document.head.appendChild(el);}function hoverDevice(){if(typeof window===\"undefined\"||!window.matchMedia)return false;return window.matchMedia(\"(hover: hover) and (pointer: fine)\").matches;}function reducedMotion(){if(typeof window===\"undefined\"||!window.matchMedia)return true;return window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;}function Shine({animation,strength=.22}){return /*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":\"true\",style:{position:\"absolute\",inset:0,overflow:\"hidden\",pointerEvents:\"none\",zIndex:20,borderRadius:\"inherit\"},children:/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:\"-50%\",left:\"-50%\",width:\"200%\",height:\"200%\",background:\"linear-gradient(135deg, rgba(255,255,255,0) 44%, rgba(255,255,255,\"+strength+\") 50%, rgba(255,255,255,0) 56%)\",mixBlendMode:\"screen\",animation}})});}function makeOverride(name,opts){return function(Component){const Wrapped=/*#__PURE__*/forwardRef(function TiltShine(props,ref){const{style,children,onMouseEnter,onMouseMove,onMouseLeave,...rest}=props;const[canHover,setCanHover]=useState(false);const[motionOk,setMotionOk]=useState(false);const[hovered,setHovered]=useState(false);const[shineKey,setShineKey]=useState(0);const rx=useMotionValue(0);const ry=useMotionValue(0);const sc=useMotionValue(1);const rotateX=useSpring(rx,SPRING);const rotateY=useSpring(ry,SPRING);const scale=useSpring(sc,SPRING);useEffect(()=>{ensureKeyframes();const ok=!reducedMotion();setMotionOk(ok);setCanHover(ok&&hoverDevice());},[]);const handleEnter=e=>{onMouseEnter?.(e);if(!canHover)return;setHovered(true);setShineKey(k=>k+1);if(opts.tilt)sc.set(HOVER_SCALE);};const handleMove=e=>{onMouseMove?.(e);if(!canHover||!opts.tilt)return;const r=e.currentTarget.getBoundingClientRect();if(!r.width||!r.height)return;const px=Math.max(-.5,Math.min(.5,(e.clientX-r.left)/r.width-.5));const py=Math.max(-.5,Math.min(.5,(e.clientY-r.top)/r.height-.5));ry.set(px*2*MAX_TILT_Y);rx.set(-py*2*MAX_TILT_X);};const handleLeave=e=>{onMouseLeave?.(e);setHovered(false);rx.set(0);ry.set(0);sc.set(1);};const motionStyle=opts.tilt?{rotateX,rotateY,scale,transformPerspective:PERSPECTIVE}:{};return /*#__PURE__*/_jsxs(Component,{...rest,ref:ref,onMouseEnter:handleEnter,onMouseMove:handleMove,onMouseLeave:handleLeave,style:{...style,...motionStyle},children:[children,opts.loopShine&&motionOk&&/*#__PURE__*/_jsx(Shine,{animation:KF_LOOP+\" \"+LOOP_SECONDS+\"s cubic-bezier(0.45, 0, 0.25, 1) 0.5s infinite\"}),opts.hoverShine&&canHover&&hovered&&/*#__PURE__*/_jsx(Shine,{animation:KF_ONCE+\" 1.4s cubic-bezier(0.22, 1, 0.36, 1) forwards\"},shineKey)]});});Wrapped.displayName=name;return Wrapped;};}/** Project cards: subtle tilt toward the cursor + one shine sweep on hover. */export function withBookHover(Component){return makeOverride(\"BookHover\",{tilt:true,hoverShine:true,loopShine:false})(Component);}/** Photograph: tilt + shine on hover, plus a shine that loops on its own every few seconds. */export function withPhotoShine(Component){return makeOverride(\"PhotoShine\",{tilt:true,hoverShine:true,loopShine:true})(Component);}/** Shine only (no tilt): one sweep on hover. Used on the 3D carousel. */export function withShineOnly(Component){return makeOverride(\"ShineOnly\",{tilt:false,hoverShine:true,loopShine:false})(Component);}/**\n * Per-card shine for components whose cards we can't edit directly (e.g. the\n * linked \"Images\" carousel). Finds every image inside, adds its own shine\n * layer, and sweeps that card's shine when the cursor enters it.\n */export function withCardShines(Component){const Wrapped=/*#__PURE__*/forwardRef(function CardShines(props,ref){const hostRef=useRef(null);useEffect(()=>{const root=hostRef.current;if(!root||reducedMotion()||!hoverDevice())return;ensureKeyframes();const cleanups=[];const attach=()=>{root.querySelectorAll(\"img\").forEach(img=>{const wrap=img.parentElement;if(!wrap||wrap.querySelector(\":scope > [data-card-shine]\"))return;const card=wrap.parentElement||wrap;const layer=document.createElement(\"div\");layer.setAttribute(\"data-card-shine\",\"\");layer.setAttribute(\"aria-hidden\",\"true\");Object.assign(layer.style,{position:\"absolute\",inset:\"0\",overflow:\"hidden\",pointerEvents:\"none\",borderRadius:\"inherit\",zIndex:\"2\"});const band=document.createElement(\"div\");Object.assign(band.style,{position:\"absolute\",top:\"-50%\",left:\"-50%\",width:\"200%\",height:\"200%\",background:\"linear-gradient(135deg, rgba(255,255,255,0) 44%, rgba(255,255,255,0.28) 50%, rgba(255,255,255,0) 56%)\",mixBlendMode:\"screen\",opacity:\"0\"});layer.appendChild(band);wrap.appendChild(layer);const play=()=>{band.style.animation=\"none\";void band.offsetWidth;band.style.animation=KF_ONCE+\" 1.4s cubic-bezier(0.22, 1, 0.36, 1) forwards\";};card.addEventListener(\"mouseenter\",play);cleanups.push(()=>{card.removeEventListener(\"mouseenter\",play);layer.remove();});});};attach();const mo=new MutationObserver(()=>attach());mo.observe(root,{childList:true,subtree:true});return()=>{mo.disconnect();cleanups.forEach(fn=>fn());};},[]);return /*#__PURE__*/_jsx(\"div\",{ref:hostRef,style:{display:\"contents\"},children:/*#__PURE__*/_jsx(Component,{...props,ref:ref})});});Wrapped.displayName=\"CardShines\";return Wrapped;}\nexport const __FramerMetadata__ = {\"exports\":{\"withPhotoShine\":{\"type\":\"reactHoc\",\"name\":\"withPhotoShine\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCardShines\":{\"type\":\"reactHoc\",\"name\":\"withCardShines\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withBookHover\":{\"type\":\"reactHoc\",\"name\":\"withBookHover\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withShineOnly\":{\"type\":\"reactHoc\",\"name\":\"withShineOnly\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BookHover.map"],"mappings":"A,iNAIsE,SAASe,GAAiB,CAAyC,GAArC,OAAO,SAAW,KAAsB,SAAS,eAAeC,CAAO,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