{"version":3,"file":"TimeCounter.DwrAtPCZ.mjs","names":["useState","useEffect","startTransition","_jsx","__esmMin","init_npm_react_18_3_1","te","ce","init_jsx_runtime","c","_e","useIsStaticRenderer","init_framer_BWzg2IRg","ControlType","addPropertyControls","TimeCounter","props","countUp","startTime","startFrom","showHours","showMilliseconds","autoStart","textColor","backgroundColor","font","padding","style","time","setTime","isRunning","setIsRunning","isStatic","interval","prevTime","newTime","formatTime","milliseconds","totalSeconds","hours","minutes","seconds","ms","timeString","isFixedWidth","init_TimeCounter"],"sources":["https:/framerusercontent.com/modules/1SF7pZs1u5UVOIQABLrj/y0b2HnZkY3hMlpVtUXRr/TimeCounter.js"],"sourcesContent":["// Time counter component that counts up from zero or a specified start time\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * Time Counter\n * \n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 100\n * \n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function TimeCounter(props){const{countUp=true,startTime=0,startFrom=0,showHours=true,showMilliseconds=false,autoStart=true,textColor=\"#000000\",backgroundColor=\"#FFFFFF\",font,padding=\"20px\",style}=props;const[time,setTime]=useState(startFrom*1e3);const[isRunning,setIsRunning]=useState(autoStart);const isStatic=useIsStaticRenderer();useEffect(()=>{if(isStatic||!isRunning)return;const interval=setInterval(()=>{startTransition(()=>{setTime(prevTime=>{if(countUp){return prevTime+(showMilliseconds?10:1e3);}else{const newTime=prevTime-(showMilliseconds?10:1e3);if(newTime<=0){setIsRunning(false);return 0;}return newTime;}});});},showMilliseconds?10:1e3);return()=>clearInterval(interval);},[isRunning,countUp,showMilliseconds,isStatic]);const formatTime=milliseconds=>{const totalSeconds=Math.floor(milliseconds/1e3);const hours=Math.floor(totalSeconds/3600);const minutes=Math.floor(totalSeconds%3600/60);const seconds=totalSeconds%60;const ms=Math.floor(milliseconds%1e3/10);let timeString=\"\";if(showHours){timeString+=`${hours.toString().padStart(2,\"0\")}:`;}timeString+=`${minutes.toString().padStart(2,\"0\")}:${seconds.toString().padStart(2,\"0\")}`;if(showMilliseconds){timeString+=`.${ms.toString().padStart(2,\"0\")}`;}return timeString;};const isFixedWidth=style?.width===\"100%\";return /*#__PURE__*/_jsx(\"div\",{style:{...style,position:\"relative\",display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",gap:20,padding,backgroundColor,borderRadius:8,...isFixedWidth?{}:{minWidth:\"max-content\"}},children:/*#__PURE__*/_jsx(\"div\",{style:{...font,color:textColor,fontVariantNumeric:\"tabular-nums\"},children:formatTime(time)})});}addPropertyControls(TimeCounter,{startFrom:{type:ControlType.Number,title:\"Start From\",defaultValue:0,min:0,step:1,unit:\"s\",displayStepper:true},countUp:{type:ControlType.Boolean,title:\"Direction\",defaultValue:true,enabledTitle:\"Count Up\",disabledTitle:\"Count Down\"},startTime:{type:ControlType.Number,title:\"Start Time\",defaultValue:0,min:0,step:1e3,unit:\"ms\",displayStepper:true},autoStart:{type:ControlType.Boolean,title:\"Auto Start\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"},showHours:{type:ControlType.Boolean,title:\"Show Hours\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},showMilliseconds:{type:ControlType.Boolean,title:\"Milliseconds\",defaultValue:false,enabledTitle:\"Show\",disabledTitle:\"Hide\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"48px\",variant:\"Semibold\",letterSpacing:\"-0.02em\",lineHeight:\"1em\"}},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"20px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TimeCounter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"300\",\"framerIntrinsicHeight\":\"100\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TimeCounter.map"],"mappings":"A,gMASG,SAAwBe,EAAYC,EAAM,CAAC,GAAK,CAACC,UAAQ,GAAKC,YAAU,EAAEC,YAAU,EAAEC,YAAU,GAAKC,mBAAiB,GAAMC,YAAU,GAAKC,YAAU,UAAUC,kBAAgB,UAAUC,OAAKC,UAAQ,OAAOC,SAAOX,EAAW,CAACY,EAAKC,GAAS7B,EAASmB,EAAU,GAAG,EAAO,CAACW,EAAUC,GAAc/B,EAASsB,CAAS,EAAQU,EAASrB,EAAoB,EAAEV,MAAc,CAAC,GAAG+B,GAAU,CAACF,EAAU,OAAO,IAAMG,EAAS,gBAAgB,CAAC/B,MAAoB,CAAC2B,EAAQK,GAAU,CAAC,GAAGjB,EAAS,OAAOiB,GAAUb,EAAiB,GAAG,KAAU,CAAC,IAAMc,EAAQD,GAAUb,EAAiB,GAAG,KAAkD,OAA1Cc,GAAS,GAAGJ,EAAa,EAAK,EAAS,GAAUI,CAAQ,CAAC,CAAC,CAAE,CAAC,CAAE,EAAEd,EAAiB,GAAG,GAAG,EAAE,UAAU,cAAcY,CAAQ,CAAE,EAAE,CAACH,EAAUb,EAAQI,EAAiBW,CAAQ,CAAC,EAAE,IAAMI,EAAWC,GAAc,CAAC,IAAMC,EAAa,KAAK,MAAMD,EAAa,GAAG,EAAQE,EAAM,KAAK,MAAMD,EAAa,IAAI,EAAQE,EAAQ,KAAK,MAAMF,EAAa,KAAK,EAAE,EAAQG,EAAQH,EAAa,GAASI,EAAG,KAAK,MAAML,EAAa,IAAI,EAAE,EAAMM,EAAW,GAAqO,OAA/NvB,IAAWuB,GAAY,GAAGJ,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