{"version":3,"file":"CustomCursor.BAfVs8h0.mjs","names":["useRef","useState","_Fragment"],"sources":["https:/framerusercontent.com/modules/RLaoVspxwS5RXM8rBu6J/4IIyPax2FjjpMPtJMA6s/CustomCursor.js"],"sourcesContent":["// Custom Cursor — Nir Raizes\n// Framer Component\n//\n// HOW TO INSTALL:\n// 1. In Framer, open Assets panel → Code → + New File\n// 2. Paste this entire file\n// 3. Drag \"CustomCursor\" onto your page once — place it anywhere\n// 4. It automatically hides the default cursor site-wide\n// 5. Cursor color adapts automatically — dark on light backgrounds, light on dark backgrounds\nimport{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect,useRef,useState}from\"react\";export default function CustomCursor({dotSize=8,ringSize=36,ringThickness=1,ringLag=.12,hoverScale=1.8,hoverRingColor=\"#C9A84C\",lightColor=\"#FFFFFF\",darkColor=\"#0D0C0A\",luminanceThreshold=128}){const dotRef=useRef(null);const ringRef=useRef(null);const mouse=useRef({x:-100,y:-100});const ring=useRef({x:-100,y:-100});const raf=useRef(0);const hovering=useRef(false);const currentColor=useRef(darkColor);const[mounted,setMounted]=useState(false);// ── Get background luminance at a point using canvas sampling\nconst getBackgroundColor=(x,y)=>{// Walk up the DOM tree from the element at the cursor position\n// and find the first element with a non-transparent background\nconst elements=document.elementsFromPoint(x,y);for(const el of elements){if(el===dotRef.current||el===ringRef.current)continue;const bg=window.getComputedStyle(el).backgroundColor;// Skip transparent/none\nif(!bg||bg===\"transparent\"||bg===\"rgba(0, 0, 0, 0)\")continue;return bg;}// Default to white if nothing found\nreturn\"rgb(255, 255, 255)\";};// ── Parse rgb/rgba string → { r, g, b }\nconst parseRGB=color=>{const match=color.match(/rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)/);if(!match)return{r:255,g:255,b:255};return{r:parseInt(match[1]),g:parseInt(match[2]),b:parseInt(match[3])};};// ── Calculate perceived luminance (0-255)\nconst getLuminance=(r,g,b)=>{// Standard perceived brightness formula\nreturn .299*r+.587*g+.114*b;};// ── Update cursor color based on background\nconst updateCursorColor=(x,y)=>{const bg=getBackgroundColor(x,y);const{r,g,b}=parseRGB(bg);const luminance=getLuminance(r,g,b);const newColor=luminance>luminanceThreshold?darkColor:lightColor;if(newColor!==currentColor.current){currentColor.current=newColor;if(dotRef.current){dotRef.current.style.background=newColor;}if(ringRef.current&&!hovering.current){// Ring color: same hue but more transparent\nconst isLight=newColor===lightColor;ringRef.current.style.borderColor=isLight?\"rgba(255,255,255,0.5)\":\"rgba(13,12,10,0.4)\";}}};useEffect(()=>{setMounted(true);// Hide native cursor globally\nconst style=document.createElement(\"style\");style.id=\"__nir-cursor-hide__\";style.textContent=\"*, *::before, *::after { cursor: none !important; }\";document.head.appendChild(style);const onMove=e=>{mouse.current={x:e.clientX,y:e.clientY};// Snap dot directly to cursor — no lag\nif(dotRef.current){dotRef.current.style.transform=`translate(${e.clientX}px, ${e.clientY}px) translate(-50%, -50%)`;}// Update color based on background at cursor position\nupdateCursorColor(e.clientX,e.clientY);};// Detect hover on interactive elements\nconst onEnter=e=>{const t=e.target;const isInteractive=t.tagName===\"A\"||t.tagName===\"BUTTON\"||t.closest(\"a\")!==null||t.closest(\"button\")!==null||t.getAttribute(\"role\")===\"button\"||t.getAttribute(\"role\")===\"link\"||window.getComputedStyle(t).cursor===\"pointer\";if(isInteractive){hovering.current=true;if(ringRef.current){ringRef.current.style.borderColor=hoverRingColor;}}};const onLeave=e=>{const t=e.relatedTarget;if(!t){hovering.current=false;return;}const isInteractive=t.tagName===\"A\"||t.tagName===\"BUTTON\"||t.closest(\"a\")!==null||t.closest(\"button\")!==null||t.getAttribute(\"role\")===\"button\"||window.getComputedStyle(t).cursor===\"pointer\";if(!isInteractive){hovering.current=false;// Restore ring color based on current background\nif(ringRef.current){const isLight=currentColor.current===darkColor;ringRef.current.style.borderColor=isLight?\"rgba(13,12,10,0.4)\":\"rgba(255,255,255,0.5)\";}}};// Smooth ring follow via rAF\nconst tick=()=>{ring.current.x+=(mouse.current.x-ring.current.x)*ringLag;ring.current.y+=(mouse.current.y-ring.current.y)*ringLag;if(ringRef.current){const scale=hovering.current?hoverScale:1;ringRef.current.style.transform=`translate(${ring.current.x}px, ${ring.current.y}px) translate(-50%, -50%) scale(${scale})`;}raf.current=requestAnimationFrame(tick);};document.addEventListener(\"mousemove\",onMove);document.addEventListener(\"mouseover\",onEnter);document.addEventListener(\"mouseout\",onLeave);raf.current=requestAnimationFrame(tick);return()=>{document.removeEventListener(\"mousemove\",onMove);document.removeEventListener(\"mouseover\",onEnter);document.removeEventListener(\"mouseout\",onLeave);cancelAnimationFrame(raf.current);document.getElementById(\"__nir-cursor-hide__\")?.remove();};},[ringLag,hoverScale,hoverRingColor,lightColor,darkColor,luminanceThreshold]);// Return a 1x1 invisible div when not mounted\n// so Framer can place it on the canvas\nif(!mounted)return /*#__PURE__*/_jsx(\"div\",{style:{width:1,height:1}});return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"div\",{ref:dotRef,style:{position:\"fixed\",top:0,left:0,width:dotSize,height:dotSize,borderRadius:\"50%\",background:darkColor,pointerEvents:\"none\",zIndex:99999,willChange:\"transform\",transition:\"background 0.2s ease\"}}),/*#__PURE__*/_jsx(\"div\",{ref:ringRef,style:{position:\"fixed\",top:0,left:0,width:ringSize,height:ringSize,borderRadius:\"50%\",border:`${ringThickness}px solid rgba(13,12,10,0.4)`,background:\"transparent\",pointerEvents:\"none\",zIndex:99998,willChange:\"transform\",transition:\"border-color 0.2s ease, transform 0.15s ease\"}})]});}// ── Framer property controls ────────────────────────────\naddPropertyControls(CustomCursor,{dotSize:{type:ControlType.Number,title:\"Dot Size\",defaultValue:8,min:2,max:24,step:1,displayStepper:true},ringSize:{type:ControlType.Number,title:\"Ring Size\",defaultValue:36,min:16,max:80,step:2,displayStepper:true},ringThickness:{type:ControlType.Number,title:\"Ring Thickness\",defaultValue:1,min:1,max:4,step:.5,displayStepper:true},ringLag:{type:ControlType.Number,title:\"Ring Lag\",description:\"How loosely the ring follows. 0.02 = tight, 0.3 = very floaty\",defaultValue:.12,min:.02,max:.3,step:.01},hoverScale:{type:ControlType.Number,title:\"Hover Scale\",defaultValue:1.8,min:1,max:4,step:.1,displayStepper:true},hoverRingColor:{type:ControlType.Color,title:\"Hover Ring Color\",defaultValue:\"#C9A84C\"},darkColor:{type:ControlType.Color,title:\"Dark Cursor\",description:\"Used on light backgrounds\",defaultValue:\"#0D0C0A\"},lightColor:{type:ControlType.Color,title:\"Light Cursor\",description:\"Used on dark backgrounds\",defaultValue:\"#FFFFFF\"},luminanceThreshold:{type:ControlType.Number,title:\"Switch Threshold\",description:\"0-255. Lower = switches to light cursor sooner\",defaultValue:128,min:0,max:255,step:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CustomCursor\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CustomCursor.map"],"mappings":"oNASgL,SAAwB,EAAa,CAAC,UAAQ,EAAE,WAAS,GAAG,gBAAc,EAAE,UAAQ,IAAI,aAAW,IAAI,iBAAe,UAAU,aAAW,UAAU,YAAU,UAAU,qBAAmB,KAAK,CAAC,IAAM,EAAOA,EAAO,KAAK,CAAO,EAAQA,EAAO,KAAK,CAAO,EAAMA,EAAO,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAO,EAAKA,EAAO,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAO,EAAIA,EAAO,EAAE,CAAO,EAASA,EAAO,GAAM,CAAO,EAAaA,EAAO,EAAU,CAAM,CAAC,EAAQ,GAAYC,EAAS,GAAM,CACvmB,GAAoB,EAAE,IAAI,CAEhC,IAAM,EAAS,SAAS,kBAAkB,EAAE,EAAE,CAAC,IAAI,IAAM,KAAM,EAAS,CAAC,GAAG,IAAK,EAAO,SAAS,IAAK,EAAQ,QA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