{"version":3,"file":"InputControl.btQ8kDhd.mjs","names":["useState","useRef","weightKg","heightM"],"sources":["https:/framerusercontent.com/modules/jbco7yWaLvDmbV3fljdF/DoFY7Oc9m5jm3HX5e6vD/InputControl.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{ControlType,addPropertyControls}from\"framer\";import{useEffect,useState,useRef}from\"react\";export default function InputControl(props){const[value,setValue]=useState(null);const[isFocused,setIsFocused]=useState(false);const inputRef=useRef(null);const{cookieName,name,placeholder,label,minVal,maxVal,nextInputId,onEnterAction,onEnterUrl}=props;const handleValueChange=e=>{let newValue=Number(e.target.value);setValue(newValue);document.cookie=`${cookieName}=${newValue}; path=/;`;};const handleKeyDown=e=>{if(e.key===\"Enter\"){e.preventDefault();// Check the action type\nif(onEnterAction===\"nextInput\"&&nextInputId){// Focus on the next input field\nconst nextInput=document.querySelector(`input[data-input-id=\"${nextInputId}\"]`);if(nextInput){nextInput.focus();}}else if(onEnterAction===\"navigate\"&&onEnterUrl){// Navigate to the specified URL\nwindow.location.href=onEnterUrl;}else if(onEnterAction===\"submit\"){// Submit the form (if within a form)\nconst form=inputRef.current?.closest(\"form\");if(form){form.requestSubmit();}}}};// Load initial value from cookie\nuseEffect(()=>{const cookieValue=getCookieValue(cookieName);if(cookieValue){setValue(parseFloat(cookieValue));}},[cookieName]);return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",flex:\"1 1\",position:\"relative\",alignSelf:\"stretch\",justifySelf:\"stretch\"},children:[/*#__PURE__*/_jsx(\"input\",{ref:inputRef,type:\"number\",name:name,placeholder:placeholder,value:value||\"\",onChange:handleValueChange,onKeyDown:handleKeyDown,onFocus:()=>setIsFocused(true),onBlur:()=>setIsFocused(false),min:minVal,max:maxVal,\"data-input-id\":cookieName,style:{backgroundColor:\"rgb(265, 265, 265)\",border:isFocused?\"0.0625rem solid #1E663E\":\"0.0625rem solid rgba(136, 136, 136, 0.1)\",borderRadius:\"4px\",color:\"rgb(26, 26, 26)\",padding:\"1.5rem\",fontSize:\"16px\",position:\"relative\",flex:\"1 1\",width:\"100%\",zIndex:1,fontFamily:\"var(--gilroy_medium)\",outline:\"none\"},required:true}),/*#__PURE__*/_jsx(\"span\",{style:{fontSize:\"16px\",color:\"rgb(26, 26, 26)\",position:\"absolute\",zIndex:2,right:\"3rem\",top:\"50%\",transform:\"translate(0%, -50%)\",fontFamily:\"var(--gilroy_medium)\"},children:label})]},cookieName);}addPropertyControls(InputControl,{minVal:{type:ControlType.Number,title:\"Min value\"},maxVal:{type:ControlType.Number,title:\"Max value\"},cookieName:{type:ControlType.String,title:\"Cookie name\"},name:{type:ControlType.String,title:\"Name\"},placeholder:{type:ControlType.String,title:\"Placeholder\"},label:{type:ControlType.String,title:\"Label\"},onEnterAction:{type:ControlType.Enum,title:\"On Enter Action\",options:[\"nextInput\",\"navigate\",\"submit\",\"none\"],optionTitles:[\"Next Input\",\"Navigate to URL\",\"Submit Form\",\"None\"],defaultValue:\"none\"},nextInputId:{type:ControlType.String,title:\"Next Input ID\",description:\"Name of the next input to focus\",hidden:props=>props.onEnterAction!==\"nextInput\"},onEnterUrl:{type:ControlType.String,title:\"Navigation URL\",description:\"URL to navigate to on Enter\",hidden:props=>props.onEnterAction!==\"navigate\"}});const getCookieValue=name=>{const cookies=document.cookie.split(\"; \");for(const cookie of cookies){const[key,val]=cookie.split(\"=\");if(key===name){return decodeURIComponent(val);}}return null;};function GraphLabel({children}){return /*#__PURE__*/_jsx(\"div\",{style:{textAlign:\"center\",color:\"#fff\",fontSize:\"1rem\",fontFamily:\"var(--gilroy_semibold)\",fontWeight:600},children:children});}export function WeightCurrent(){const[value,setValue]=useState(0);const[label,setLabel]=useState(\"lb\");useEffect(()=>{// Retrieve the cookie value\nconst weightKg=getCookieValue(\"current_weight_kg\");const weightLb=getCookieValue(\"current_weight_lb\");const goalKg=getCookieValue(\"goal_weight_kg\");const goalLb=getCookieValue(\"goal_weight_lb\");if(weightLb&&goalLb){setValue(parseFloat(weightLb));setLabel(\"lb\");return;}if(weightKg&&goalKg){setValue(parseFloat(weightKg));setLabel(\"kg\");return;}},[]);return /*#__PURE__*/_jsx(GraphLabel,{children:/*#__PURE__*/_jsxs(\"span\",{style:{whiteSpace:\"nowrap\"},children:[value,\" \",label]})});}export function WeightGoal(){const[value,setValue]=useState(0);const[label,setLabel]=useState(\"lb\");useEffect(()=>{// Retrieve the cookie value\nconst weightKg=getCookieValue(\"current_weight_kg\");const weightLb=getCookieValue(\"current_weight_lb\");const goalKg=getCookieValue(\"goal_weight_kg\");const goalLb=getCookieValue(\"goal_weight_lb\");if(weightLb&&goalLb){setValue(parseFloat(goalLb));setLabel(\"lb\");return;}if(weightKg&&goalKg){setValue(parseFloat(goalKg));setLabel(\"kg\");return;}},[]);return /*#__PURE__*/_jsx(GraphLabel,{children:/*#__PURE__*/_jsxs(\"span\",{style:{whiteSpace:\"nowrap\"},children:[value,\" \",label]})});}export function BMIScale({bmiPercentage}){const[bmi,setBMI]=useState(null);useEffect(()=>{// Retrieve the cookie values\nconst weightKg=parseFloat(getCookieValue(\"current_weight_kg\")||\"0\");const weightLb=parseFloat(getCookieValue(\"current_weight_lb\")||\"0\");const heightFt=parseInt(getCookieValue(\"height_ft\")||\"0\",10);const heightIn=parseInt(getCookieValue(\"height_in\")||\"0\",10);const heightCm=parseFloat(getCookieValue(\"height_cm\")||\"0\");// Function to calculate BMI\nconst calculateBMI=(weightKg,heightM)=>{return weightKg/heightM**2;};// Convert height to meters\nlet heightM=null;if(heightFt&&heightIn){// Combine feet and inches, then convert to meters\nconst totalInches=heightFt*12+heightIn;heightM=totalInches*.0254// Convert inches to meters\n;}else if(heightCm){// Convert centimeters to meters\nheightM=heightCm/100;}// Calculate BMI based on weight and height\nif(heightM){if(weightLb){// Convert pounds to kilograms\nconst weightKgFromLb=weightLb*.453592;setBMI(calculateBMI(weightKgFromLb,heightM));}else if(weightKg){setBMI(calculateBMI(weightKg,heightM));}}},[]);// Define the minimum and maximum BMI for scaling\nconst minBMI=18.5;const maxBMI=34.9;// Normalize BMI to a percentage scale between minBMI and maxBMI\nconst clampedPercentage=bmi!==null?Math.min(100,Math.max(0,(bmi-minBMI)/(maxBMI-minBMI)*100)):0;return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",position:\"relative\"},children:/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:\"50%\",left:`${clampedPercentage}%`,width:\"0.25rem\",height:\"3rem\",backgroundColor:\"black\",transform:\"translate(-0.125rem, -50%)\"}})});}export function BMILabel(){const[bmi,setBMI]=useState(0);useEffect(()=>{// Retrieve the cookie values\nconst weightKg=parseFloat(getCookieValue(\"current_weight_kg\")||\"0\");const weightLb=parseFloat(getCookieValue(\"current_weight_lb\")||\"0\");const heightFt=parseInt(getCookieValue(\"height_ft\")||\"0\",10);const heightIn=parseInt(getCookieValue(\"height_in\")||\"0\",10);const heightCm=parseFloat(getCookieValue(\"height_cm\")||\"0\");// Function to calculate BMI\nconst calculateBMI=(weightKg,heightM)=>{return weightKg/heightM**2;};// Convert height to meters\nlet heightM=null;if(heightFt&&heightIn){// Combine feet and inches, then convert to meters\nconst totalInches=heightFt*12+heightIn;heightM=totalInches*.0254// Convert inches to meters\n;}else if(heightCm){// Convert centimeters to meters\nheightM=heightCm/100;}// Calculate BMI based on weight and height\nif(heightM){if(weightLb){// Convert pounds to kilograms\nconst weightKgFromLb=weightLb*.453592;setBMI(calculateBMI(weightKgFromLb,heightM));}else if(weightKg){setBMI(calculateBMI(weightKg,heightM));}}},[]);return /*#__PURE__*/_jsx(\"div\",{style:bmi&&bmi<19.5?{color:\"#000\"}:bmi&&bmi<=24.9?{color:\"#34A564\"}:bmi&&bmi<=29.9?{color:\"#e3a542\"}:bmi&&bmi<=34.9?{color:\"#ba0809\"}:{color:\"#ba0809\"},children:/*#__PURE__*/_jsx(\"span\",{style:{fontFamily:\"var(--gilroy_semibold)\",fontWeight:600,fontSize:\"1.75rem\"},children:bmi&&bmi.toFixed(1)})});}export function goalInKg(){const[value,setValue]=useState(0);useEffect(()=>{const weightCookie=getCookieValue(\"goal_weight_kg\");if(weightCookie){setValue(parseFloat(weightCookie));}},[]);return /*#__PURE__*/_jsx(GraphLabel,{children:value});}export function weightInLb(){const[value,setValue]=useState(0);useEffect(()=>{const weightCookie=getCookieValue(\"current_weight_lb\");if(weightCookie){setValue(parseFloat(weightCookie));}},[]);return /*#__PURE__*/_jsx(GraphLabel,{children:value});}export function goalInLb(){const[value,setValue]=useState(0);useEffect(()=>{const weightCookie=getCookieValue(\"goal_weight_lb\");if(weightCookie){setValue(parseFloat(weightCookie));}},[]);return /*#__PURE__*/_jsx(GraphLabel,{children:value});}export function heightInFeet(){const[value,setValue]=useState(0);useEffect(()=>{const weightCookie=getCookieValue(\"height_ft\");if(weightCookie){setValue(parseFloat(weightCookie));}},[]);return /*#__PURE__*/_jsx(\"div\",{children:value});}export function heightInCm(){const[value,setValue]=useState(0);useEffect(()=>{const weightCookie=getCookieValue(\"height_cm\");if(weightCookie){setValue(parseFloat(weightCookie));}},[]);return /*#__PURE__*/_jsx(\"div\",{children:value});}export function heightInInches(){const[value,setValue]=useState(0);useEffect(()=>{const weightCookie=getCookieValue(\"height_in\");if(weightCookie){setValue(parseFloat(weightCookie));}},[]);return /*#__PURE__*/_jsx(\"div\",{children:value});}\nexport const __FramerMetadata__ = {\"exports\":{\"goalInKg\":{\"type\":\"reactComponent\",\"name\":\"goalInKg\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"heightInFeet\":{\"type\":\"reactComponent\",\"name\":\"heightInFeet\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"heightInCm\":{\"type\":\"reactComponent\",\"name\":\"heightInCm\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"BMIScale\":{\"type\":\"reactComponent\",\"name\":\"BMIScale\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"goalInLb\":{\"type\":\"reactComponent\",\"name\":\"goalInLb\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"weightInLb\":{\"type\":\"reactComponent\",\"name\":\"weightInLb\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"BMILabel\":{\"type\":\"reactComponent\",\"name\":\"BMILabel\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"default\":{\"type\":\"reactComponent\",\"name\":\"InputControl\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"WeightCurrent\":{\"type\":\"reactComponent\",\"name\":\"WeightCurrent\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"WeightGoal\":{\"type\":\"reactComponent\",\"name\":\"WeightGoal\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"heightInInches\":{\"type\":\"reactComponent\",\"name\":\"heightInInches\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./InputControl.map"],"mappings":"yMAA0J,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,EAAM,GAAUA,EAAS,KAAK,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAO,EAASC,EAAO,KAAK,CAAM,CAAC,aAAW,OAAK,cAAY,QAAM,SAAO,SAAO,cAAY,gBAAc,cAAY,EAKlR,OAA/H,MAAc,CAAC,IAAM,EAAY,EAAe,EAAW,CAAI,GAAa,EAAS,WAAW,EAAY,CAAC,EAAI,CAAC,EAAW,CAAC,CAAqB,EAAM,MAAM,CAAC,MAAM,CAAC,MAAM,OAAO,KAAK,MAAM,SAAS,WAAW,UAAU,UAAU,YAAY,UAAU,CAAC,SAAS,CAAc,EAAK,QAAQ,CAAC,IAAI,EAAS,KAAK,SAAc,OAAiB,cAAY,MAAM,GAAO,GAAG,SAL+D,GAAG,CAAC,IAAI,EAAS,OAAO,EAAE,OAAO,MAAM,CAAC,EAAS,EAAS,CAAC,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