{"version":3,"file":"PixelTrailCursor.D0jV2GE6.mjs","names":["useState","useRef","startTransition","p","useMemo"],"sources":["https:/framerusercontent.com/modules/naNfz0YNN8RlI78riNAZ/wHNmVZ8HSpE1nyWVLYET/PixelTrailCursor.js"],"sourcesContent":["// Custom desktop-only pixel trail cursor effect\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState,useMemo,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer,RenderTarget}from\"framer\";/**\n * PixelTrailCursor\n *\n * Custom desktop-only cursor effect: pixel trail, grid snapping, lag, fade, minimal monochrome, accessibility, no pointer interference.\n *\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 300\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function PixelTrailCursor(props){const{backgroundColor,pixelColor,gridSize,pixelSize,trailLength,fadeDuration,lag,style}=props;const isStatic=useIsStaticRenderer();const[isTouch,setIsTouch]=useState(false);const[reducedMotion,setReducedMotion]=useState(false);const[show,setShow]=useState(true);const[mouse,setMouse]=useState({x:0,y:0});const[trail,setTrail]=useState([]);const lagged=useRef({x:0,y:0});const frame=useRef(null);// Detect touch devices\nuseEffect(()=>{if(typeof window===\"undefined\")return;function handleTouch(){startTransition(()=>setIsTouch(true));}window.addEventListener(\"touchstart\",handleTouch,{once:true});return()=>window.removeEventListener(\"touchstart\",handleTouch);},[]);// Detect prefers-reduced-motion\nuseEffect(()=>{if(typeof window===\"undefined\")return;const mq=window.matchMedia(\"(prefers-reduced-motion: reduce)\");startTransition(()=>setReducedMotion(mq.matches));const handler=()=>startTransition(()=>setReducedMotion(mq.matches));mq.addEventListener(\"change\",handler);return()=>mq.removeEventListener(\"change\",handler);},[]);// Hide on mobile/touch or static/thumbnail\nuseEffect(()=>{if(isTouch||isStatic||RenderTarget.current()===RenderTarget.thumbnail){startTransition(()=>setShow(false));}else{startTransition(()=>setShow(true));}},[isTouch,isStatic]);// Mouse move handler\nuseEffect(()=>{if(!show)return;if(typeof window===\"undefined\")return;function onMove(e){const x=e.clientX;const y=e.clientY;startTransition(()=>setMouse({x,y}));}window.addEventListener(\"mousemove\",onMove);return()=>window.removeEventListener(\"mousemove\",onMove);},[show]);// Animation frame for lag and trail\nuseEffect(()=>{if(!show)return;let running=true;function animate(){if(!running)return;// Lagged position\nlagged.current.x+=(mouse.x-lagged.current.x)*lag;lagged.current.y+=(mouse.y-lagged.current.y)*lag;// Snap to grid\nconst snappedX=Math.round(lagged.current.x/gridSize)*gridSize;const snappedY=Math.round(lagged.current.y/gridSize)*gridSize;// Add to trail\nsetTrail(prev=>{const now=Date.now();const next=[{x:snappedX,y:snappedY,t:now},...prev.filter(p=>now-p.t<fadeDuration)];return next.slice(0,trailLength);});frame.current=requestAnimationFrame(animate);}frame.current=requestAnimationFrame(animate);return()=>{running=false;if(frame.current)cancelAnimationFrame(frame.current);};},[mouse,show,gridSize,lag,fadeDuration,trailLength]);// Hide system cursor\nuseEffect(()=>{if(!show)return;if(typeof document===\"undefined\")return;const prev=document.body.style.cursor;document.body.style.cursor=\"none\";return()=>{document.body.style.cursor=prev;};},[show]);// Minimal trail for reduced motion\nconst effectiveTrail=useMemo(()=>{if(reducedMotion)return trail.slice(0,1);return trail;},[trail,reducedMotion]);// Render nothing if not shown\nif(!show)return null;// Render overlay\nreturn /*#__PURE__*/_jsxs(\"div\",{style:{pointerEvents:\"none\",position:\"fixed\",left:0,top:0,width:\"100vw\",height:\"100vh\",zIndex:2147483647,background:\"none\",...style},\"aria-hidden\":\"true\",children:[effectiveTrail.map((p,i)=>{const age=Date.now()-p.t;const opacity=Math.max(0,1-age/fadeDuration);return /*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",left:p.x-pixelSize/2,top:p.y-pixelSize/2,width:pixelSize,height:pixelSize,background:pixelColor,opacity,borderRadius:2,boxShadow:`0 0 0 1px ${backgroundColor}`,transition:reducedMotion?\"none\":`opacity ${fadeDuration}ms linear`,willChange:\"opacity, transform\"}},p.t+\"-\"+i);}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",left:lagged.current.x-pixelSize/2,top:lagged.current.y-pixelSize/2,width:pixelSize,height:pixelSize,background:pixelColor,borderRadius:2,boxShadow:`0 0 0 1px ${backgroundColor}`,opacity:1,willChange:\"transform\"}})]});}addPropertyControls(PixelTrailCursor,{backgroundColor:{type:ControlType.Color,title:\"BG Color\",defaultValue:\"#181818\"},pixelColor:{type:ControlType.Color,title:\"Pixel Color\",defaultValue:\"#fff\"},gridSize:{type:ControlType.Number,title:\"Grid Size\",defaultValue:8,min:2,max:32,step:1},pixelSize:{type:ControlType.Number,title:\"Pixel Size\",defaultValue:8,min:2,max:32,step:1},trailLength:{type:ControlType.Number,title:\"Trail Length\",defaultValue:18,min:1,max:64,step:1},fadeDuration:{type:ControlType.Number,title:\"Fade (ms)\",defaultValue:400,min:100,max:2e3,step:10},lag:{type:ControlType.Number,title:\"Lag\",defaultValue:.22,min:.05,max:.5,step:.01}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"PixelTrailCursor\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"300\",\"framerIntrinsicWidth\":\"400\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PixelTrailCursor.map"],"mappings":"0OAWG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,kBAAgB,aAAW,WAAS,YAAU,cAAY,eAAa,MAAI,SAAO,EAAY,EAAS,GAAqB,CAAM,CAAC,EAAQ,GAAYA,EAAS,GAAM,CAAM,CAAC,EAAc,GAAkBA,EAAS,GAAM,CAAM,CAAC,EAAK,GAASA,EAAS,GAAK,CAAM,CAAC,EAAM,GAAUA,EAAS,CAAC,EAAE,EAAE,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