{"version":3,"file":"ProgressBar_1.ChIPdToS.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/awQGxOpYaGFjw2IDoa8M/OTb8ISieQqKccDXUGo1k/ProgressBar_1.js"],"sourcesContent":["// Customizable Progress Bar with Animated Current Value and Colored Segments\n// User can set goal, current, and breakdown entries with custom colors\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * Customizable Progress Bar\n *\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 80\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight fixed\n */function lerp(a,b,t){return a+(b-a)*t;}// Format number as CLP ($XX,XXX) currency\nfunction formatCLP(value){return\"$\"+value.toLocaleString(\"es-CL\");}export default function ProgressBar(props){const{goal,entries:propEntries,currentAmount,barHeight,barRadius,backgroundColor,labelFont,numberFont,style,globalPercentPrefix,globalPercentSuffix,globalPercentColor,globalPercentFont,fontColor}=props;const isStatic=useIsStaticRenderer();// Use currentAmount as a fetchable numeric prop for progress, fallback to entries\nlet entries=propEntries;// Build entries array from currentAmount if provided, else use propEntries\nif(currentAmount!==undefined&&currentAmount!==null&&!isNaN(Number(currentAmount))){// Force to number in case it's a string from API\nconst value=Number(currentAmount);entries=[{value,color:propEntries[0]?.color||\"#0099FF\"}];}const total=entries.reduce((sum,e)=>sum+Number(e.value),0);const progress=Math.min(total,goal);const percentOfGoal=goal>0?progress/goal*100:0;const[displayed,setDisplayed]=useState(0);const raf=useRef(null);// Empty state: no progress\nconst isEmpty=!entries.length||total===0;// Animate number on appear\nuseEffect(()=>{if(isStatic){setDisplayed(progress);return;}let start=null;let duration=900;let from=0;let to=progress;function animate(ts){if(!start)start=ts;let t=Math.min(1,(ts-start)/duration);let val=Math.round(lerp(from,to,t));startTransition(()=>setDisplayed(val));if(t<1)raf.current=requestAnimationFrame(animate);}raf.current=requestAnimationFrame(animate);return()=>raf.current&&cancelAnimationFrame(raf.current);},[progress,isStatic]);// Bar segments\nlet acc=0;const barSegments=entries.map((entry,i)=>{const width=entry.value/goal*100;const left=acc/goal*100;acc+=entry.value;return /*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",left:`${left}%`,width:`${width}%`,height:\"100%\",background:entry.color,borderTopLeftRadius:i===0?barRadius:0,borderBottomLeftRadius:i===0?barRadius:0,borderTopRightRadius:i===entries.length-1?barRadius:0,borderBottomRightRadius:i===entries.length-1?barRadius:0,transition:\"width 0.6s cubic-bezier(.4,1,.4,1)\"},\"aria-label\":entry.label},i);});// --- RESET BUTTON ---\nfunction handleReset(){startTransition(()=>setDisplayed(0));}return /*#__PURE__*/_jsxs(\"div\",{style:{...style,width:\"100%\",display:\"flex\",flexDirection:\"column\",alignItems:\"stretch\",gap:12},children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",alignItems:\"baseline\",gap:8},children:[/*#__PURE__*/_jsx(\"span\",{style:{...numberFont,fontVariantNumeric:\"tabular-nums\",minWidth:48,color:fontColor},children:isEmpty?\"$0\":formatCLP(displayed)}),/*#__PURE__*/_jsxs(\"span\",{style:{...labelFont,color:fontColor},children:[\"/ \",formatCLP(goal)]}),/*#__PURE__*/_jsxs(\"span\",{style:{...globalPercentFont,color:globalPercentColor||fontColor,marginLeft:10,fontWeight:600,display:\"inline\"},children:[globalPercentPrefix,percentOfGoal.toFixed(0),\"%\",globalPercentSuffix]})]}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",width:\"100%\",height:barHeight,background:backgroundColor,borderRadius:barRadius,overflow:\"hidden\"},\"aria-valuenow\":progress,\"aria-valuemax\":goal,\"aria-valuemin\":0,role:\"progressbar\",children:isEmpty?/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",left:0,top:0,width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",color:fontColor||\"#bbb\",fontSize:14,fontWeight:500,letterSpacing:\"-0.01em\"},children:\"S\\xe9 el primero en donar\"}):barSegments})]});}addPropertyControls(ProgressBar,{goal:{type:ControlType.Number,title:\"Goal\",defaultValue:5e3,min:1,max:1e7,step:1},// Added fetchable numeric prop for current value\ncurrentAmount:{type:ControlType.Number,title:\"Current Amount\",defaultValue:300,min:0,max:1e7,description:\"El monto recaudado actual (fetchable)\"},entries:{type:ControlType.Array,title:\"Entries\",control:{type:ControlType.Object,controls:{value:{type:ControlType.Number,title:\"Value\",defaultValue:300,min:0,max:1e7},color:{type:ControlType.Color,title:\"Bar Color\",defaultValue:\"#0099FF\"}}},defaultValue:[{value:300,color:\"#0099FF\"}],maxCount:6},barHeight:{type:ControlType.Number,title:\"Bar Height\",defaultValue:18,min:8,max:48,step:1,unit:\"px\"},barRadius:{type:ControlType.Number,title:\"Bar Radius\",defaultValue:8,min:0,max:32,step:1,unit:\"px\"},backgroundColor:{type:ControlType.Color,title:\"Bar Background\",defaultValue:\"#F5F5F5\"},labelFont:{type:ControlType.Font,title:\"Label Font\",defaultValue:{fontSize:\"15px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},numberFont:{type:ControlType.Font,title:\"Number Font\",defaultValue:{fontSize:\"32px\",variant:\"Bold\",letterSpacing:\"-0.03em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},globalPercentPrefix:{type:ControlType.String,title:\"Global % Prefix\",defaultValue:\"Goal \"},globalPercentSuffix:{type:ControlType.String,title:\"Global % Suffix\",defaultValue:\" Completed\"},globalPercentColor:{type:ControlType.Color,title:\"Global % Color\",defaultValue:\"#0099FF\"},globalPercentFont:{type:ControlType.Font,title:\"Global % Font\",defaultValue:{fontSize:\"15px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},fontColor:{type:ControlType.Color,title:\"Font Color\",defaultValue:\"#000000\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ProgressBar\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ProgressBar_1.map"],"mappings":"8MAUG,SAAS,EAAK,EAAE,EAAE,EAAE,CAAC,OAAO,GAAG,EAAE,GAAG,EACvC,SAAS,EAAU,EAAM,CAAC,MAAM,IAAI,EAAM,eAAe,QAAQ,CAAE,SAAwB,EAAY,EAAM,CAAC,GAAK,CAAC,OAAK,QAAQ,EAAY,gBAAc,YAAU,YAAU,kBAAgB,YAAU,aAAW,QAAM,sBAAoB,sBAAoB,qBAAmB,oBAAkB,aAAW,EAAY,EAAS,GAAqB,CACxV,EAAQ,EACT,GAA2C,MAAM,CAAC,MAAM,OAAO,EAAc,CAAC,GAC/C,EAAQ,CAAC,CAAC,MAAhC,OAAO,EAAc,CAAiB,MAAM,EAAY,IAAI,OAAO,UAAU,CAAC,EAAE,IAAM,EAAM,EAAQ,QAAQ,EAAI,IAAI,EAAI,OAAO,EAAE,MAAM,CAAC,EAAE,CAAO,EAAS,KAAK,IAAI,EAAM,EAAK,CAAO,EAAc,EAAK,EAAE,EAAS,EAAK,IAAI,EAAO,CAAC,EAAU,GAAcA,EAAS,EAAE,CAAO,EAAIC,EAAO,KAAK,CACpS,EAAQ,CAAC,EAAQ,QAAQ,IAAQ,EACvC,MAAc,CAAC,GAAG,EAAS,CAAC,EAAa,EAAS,CAAC,OAAQ,IAAI,EAAM,KAAqC,EAAG,EAAS,SAAS,EAAQ,EAAG,CAAC,AAAU,IAAM,EAAG,IAAI,EAAE,KAAK,IAAI,GAAG,EAAG,GAAO,IAAS,CAAK,EAAI,KAAK,MAAM,EAAK,EAAK,EAAG,EAAE,CAAC,CAAC,MAAoB,EAAa,EAAI,CAAC,CAAI,EAAE,IAAE,EAAI,QAAQ,sBAAsB,EAAQ,EAA6C,MAA3C,G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