{"version":3,"file":"ScreenSaver_Prod.BtFaZXj1.mjs","names":["React.useState","React.useRef","React.useCallback"],"sources":["https:/framerusercontent.com/modules/kAKs4SGX5PAwm3BE8By8/dtuQG7o5X02oY6WbL5ty/ScreenSaver_Prod.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{motion,AnimatePresence,useMotionValue}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";import{SettingsMessage}from\"https://framer.com/m/Utils-QTIc.js@hDBsItohjMEOACix8wDv\";const styles=`\n  .screen-saver, .screen-saver > * {\n    width: 100% !important;\n    height: 100% !important;\n  }\n  .screen-saver {\n    position: relative;\n    overflow: hidden;\n  }\n  .bouncer-container {\n    position: absolute;\n    top: 0;\n    left: 0;\n    right: 0;\n    bottom: 0;\n  }\n  .bouncer {\n    position: absolute;\n  }\n`;/**\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 200\n *\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */function ScreenSaver({background,bouncer,ms,speed,transition,style}){const[isIdle,setIsIdle]=React.useState(false);const containerRef=React.useRef(null);const bouncerRef=React.useRef(null);const[containerSize,setContainerSize]=React.useState({width:0,height:0});const[bouncerSize,setBouncerSize]=React.useState({width:0,height:0});const x=useMotionValue(0);const y=useMotionValue(0);const directionRef=React.useRef({x:1,y:1});const animationRef=React.useRef(null);const lastUpdateTime=React.useRef(0);const updateSizes=React.useCallback(()=>{if(containerRef.current){const containerRect=containerRef.current.getBoundingClientRect();setContainerSize({width:containerRect.width,height:containerRect.height});}if(bouncerRef.current){const bouncerRect=bouncerRef.current.getBoundingClientRect();setBouncerSize({width:bouncerRect.width,height:bouncerRect.height});}},[]);React.useLayoutEffect(()=>{updateSizes();const resizeObserver=new ResizeObserver(updateSizes);if(containerRef.current)resizeObserver.observe(containerRef.current);if(bouncerRef.current)resizeObserver.observe(bouncerRef.current);const mutationObserver=new MutationObserver(updateSizes);if(containerRef.current){mutationObserver.observe(containerRef.current,{childList:true,subtree:true});}return()=>{resizeObserver.disconnect();mutationObserver.disconnect();};},[updateSizes]);React.useEffect(()=>{let timeoutId;const resetTimer=()=>{clearTimeout(timeoutId);setIsIdle(false);timeoutId=setTimeout(()=>setIsIdle(true),ms);};const handleUserActivity=()=>{resetTimer();};resetTimer();// Add event listeners for various user interactions\nwindow.addEventListener(\"mousemove\",handleUserActivity);window.addEventListener(\"keydown\",handleUserActivity);window.addEventListener(\"mousedown\",handleUserActivity);window.addEventListener(\"touchstart\",handleUserActivity);window.addEventListener(\"touchmove\",handleUserActivity);window.addEventListener(\"scroll\",handleUserActivity,true)// Capture phase\n;return()=>{clearTimeout(timeoutId);window.removeEventListener(\"mousemove\",handleUserActivity);window.removeEventListener(\"keydown\",handleUserActivity);window.removeEventListener(\"mousedown\",handleUserActivity);window.removeEventListener(\"touchstart\",handleUserActivity);window.removeEventListener(\"touchmove\",handleUserActivity);window.removeEventListener(\"scroll\",handleUserActivity,true);};},[ms]);const animate=React.useCallback(timestamp=>{const deltaTime=timestamp-lastUpdateTime.current;if(deltaTime<16){// Limit to ~60 FPS\nanimationRef.current=requestAnimationFrame(animate);return;}lastUpdateTime.current=timestamp;let newX=x.get()+speed*directionRef.current.x;let newY=y.get()+speed*directionRef.current.y;if(newX+bouncerSize.width>containerSize.width||newX<0){directionRef.current.x*=-1;newX=Math.max(0,Math.min(newX,containerSize.width-bouncerSize.width));}if(newY+bouncerSize.height>containerSize.height||newY<0){directionRef.current.y*=-1;newY=Math.max(0,Math.min(newY,containerSize.height-bouncerSize.height));}x.set(newX);y.set(newY);animationRef.current=requestAnimationFrame(animate);},[speed,containerSize,bouncerSize,x,y]);React.useEffect(()=>{animationRef.current=requestAnimationFrame(animate);return()=>{if(animationRef.current){cancelAnimationFrame(animationRef.current);}};},[animate]);if(!background||background.length===0||!bouncer||bouncer.length===0){return /*#__PURE__*/_jsx(SettingsMessage,{title:\"Set Up the Component\",description:\"Add Background and Bouncer elements to the Component properties.\",containerStyle:{...style,padding:\"20px 20px 30px 20px\"}});}return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{width:\"100%\",height:\"100%\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",visibility:\"hidden\",pointerEvents:\"none\"},children:/*#__PURE__*/_jsx(\"div\",{ref:bouncerRef,children:bouncer})}),/*#__PURE__*/_jsx(AnimatePresence,{children:isIdle&&/*#__PURE__*/_jsxs(motion.div,{className:\"screen-saver\",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:transition,children:[/*#__PURE__*/_jsx(\"style\",{children:styles}),background,/*#__PURE__*/_jsx(\"div\",{className:\"bouncer-container\",children:/*#__PURE__*/_jsx(motion.div,{className:\"bouncer\",style:{x,y,width:bouncerSize.width,height:bouncerSize.height},children:bouncer})})]})})]});}ScreenSaver.defaultProps={ms:1e4,speed:1,transition:{type:\"tween\",duration:.2,ease:\"easeInOut\"}};ScreenSaver.displayName=\"Screen Saver\";addPropertyControls(ScreenSaver,{background:{type:ControlType.ComponentInstance,title:\"Background\"},bouncer:{type:ControlType.ComponentInstance,title:\"Bouncer\"},ms:{type:ControlType.Number,title:\"Idle\",description:\"Time before the screen saver activates.\",defaultValue:1e4,min:0,step:1e3,displayStepper:true,unit:\"ms\"},speed:{type:ControlType.Number,title:\"Speed\",description:\"Speed of the bouncer.\",defaultValue:1,min:0,max:10,step:.5},transition:{type:ControlType.Transition,title:\"Transition\",defaultValue:{type:\"tween\",duration:.2,ease:\"easeInOut\"},description:\"Set pointer events style to 'none' on this component so you can interact with layers below it.\\nMore components at [Framer University](https://frameruni.link/cc).\"}});export default ScreenSaver;\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScreenSaver\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerIntrinsicWidth\":\"400\",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