{"version":3,"file":"TimedFill.CzzUrAM9.mjs","names":["useState","useRef","__esmMin","init_npm_react_18_3_1","te","de","init_jsx_runtime","c","ce","_e","motion","init_framer_motion_DhsWWWsN","addPropertyControls","init_framer_BisrWwwE","ControlType","TimedFill","props","progress","setProgress","isRunning","setIsRunning","autoStart","animationFrameRef","enabled","startTime","durationMs","duration","updateProgress","elapsed","newProgress","loop","handleClick","getClipPath","direction","style","fillColor","init_TimedFill"],"sources":["https:/framerusercontent.com/modules/shqTXKW9XBF7rlED5FAt/oMNHJ13kobSMfYGLDefe/TimedFill.js"],"sourcesContent":["// Component that fills an object with color based on a time duration\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,startTransition,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion}from\"framer-motion\";/**\n * Timed Fill Component\n * Fills an object with color based on a set time duration\n *\n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 100\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function TimedFill(props){const{enabled=true,duration=5,fillColor=\"#0099FF\",backgroundColor=\"#F5F5F5\",direction=\"left-to-right\",autoStart=true,loop=false,borderRadius=8,style}=props;const[progress,setProgress]=useState(0);const[isRunning,setIsRunning]=useState(autoStart);const animationFrameRef=useRef(null);useEffect(()=>{if(!isRunning||!enabled){if(animationFrameRef.current){cancelAnimationFrame(animationFrameRef.current);}return;}const startTime=Date.now();const durationMs=duration*1e3;const updateProgress=()=>{const elapsed=Date.now()-startTime;const newProgress=Math.min(elapsed/durationMs*100,100);setProgress(newProgress);if(newProgress<100){animationFrameRef.current=requestAnimationFrame(updateProgress);}else if(loop){setProgress(0);setIsRunning(true);}else{setIsRunning(false);}};animationFrameRef.current=requestAnimationFrame(updateProgress);return()=>{if(animationFrameRef.current){cancelAnimationFrame(animationFrameRef.current);}};},[isRunning,duration,loop,enabled]);const handleClick=()=>{if(progress>=100&&!loop){startTransition(()=>{setProgress(0);setIsRunning(true);});}else{startTransition(()=>setIsRunning(!isRunning));}};const getClipPath=()=>{switch(direction){case\"left-to-right\":return`inset(0 ${100-progress}% 0 0)`;case\"right-to-left\":return`inset(0 0 0 ${100-progress}%)`;case\"top-to-bottom\":return`inset(0 0 ${100-progress}% 0)`;case\"bottom-to-top\":return`inset(${100-progress}% 0 0 0)`;default:return`inset(0 ${100-progress}% 0 0)`;}};return /*#__PURE__*/_jsx(\"div\",{style:{...style,position:\"relative\",width:\"100%\",height:\"100%\",backgroundColor,borderRadius,overflow:\"hidden\",cursor:\"pointer\"},onClick:handleClick,children:/*#__PURE__*/_jsx(motion.div,{style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",backgroundColor:fillColor,clipPath:getClipPath(),display:enabled?\"block\":\"none\"}})});}addPropertyControls(TimedFill,{enabled:{type:ControlType.Boolean,title:\"Enabled\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:5,min:.1,max:60,step:.1,unit:\"s\"},fillColor:{type:ControlType.Color,title:\"Fill Color\",defaultValue:\"#0099FF\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#F5F5F5\"},direction:{type:ControlType.Enum,title:\"Direction\",options:[\"left-to-right\",\"right-to-left\",\"top-to-bottom\",\"bottom-to-top\"],optionTitles:[\"Left to Right\",\"Right to Left\",\"Top to Bottom\",\"Bottom to Top\"],defaultValue:\"left-to-right\"},autoStart:{type:ControlType.Boolean,title:\"Auto Start\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:8,min:0,max:100,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TimedFill\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"300\",\"framerIntrinsicHeight\":\"100\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TimedFill.map"],"mappings":"A,iPAUG,SAAwBe,EAAU,EAAM,CAAC,GAAK,CAAC,UAAQ,GAAK,WAAS,EAAE,YAAU,UAAU,kBAAgB,UAAU,YAAU,gBAAgB,YAAU,GAAK,OAAK,GAAM,eAAa,EAAE,SAAOC,EAAW,CAACC,EAASC,GAAalB,EAAS,CAAC,EAAO,CAACmB,EAAUC,GAAcpB,EAASqB,CAAS,EAAQC,EAAkBrB,EAAO,IAAI,EAAEO,MAAc,CAAC,GAAG,CAACW,GAAW,CAACI,EAAQ,CAAID,EAAkB,SAAS,qBAAqBA,EAAkB,OAAO,EAAG,MAAO,CAAC,IAAME,EAAU,KAAK,IAAI,EAAQC,EAAWC,EAAS,IAAUC,MAAmB,CAAC,IAAMC,EAAQ,KAAK,IAAI,EAAEJ,EAAgBK,EAAY,KAAK,IAAID,EAAQH,EAAW,IAAI,GAAG,EAAEP,EAAYW,CAAW,EAAKA,EAAY,IAAK,EAAkB,QAAQ,sBAAsBF,CAAc,EAAWG,GAAMZ,EAAY,CAAC,EAAEE,EAAa,EAAI,GAAQA,EAAa,EAAK,CAAG,EAAkE,MAAhE,GAAkB,QAAQ,sBAAsBO,CAAc,MAAY,CAAIL,EAAkB,SAAS,qBAAqBA,EAAkB,OAAO,CAAG,CAAE,EAAE,CAACH,EAAUO,EAASI,EAAKP,CAAO,CAAC,EAAE,IAAMQ,MAAgB,CAA0B3B,EAAtBa,GAAU,KAAK,CAACa,MAA0B,CAACZ,EAAY,CAAC,EAAEE,EAAa,EAAI,CAAE,MAA6BA,EAAa,CAACD,CAAS,CAAC,CAAG,EAAQa,MAAgB,CAAC,OAAOC,EAAP,CAAkB,IAAI,gBAAgB,MAAM,WAAW,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