{"version":3,"file":"bmi-DsIT68mh.js","sources":["../../Client/features/bmi/BmiCalculatorComponent.tsx","../../Client/features/bmi/BmiResultComponent.tsx","../../Client/features/bmi/App.tsx","../../Client/features/bmi/Index.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\ntype BmiCalculatorComponentProps = {\n setPageIndex: (arg: number) => void;\n setBmi: (arg: number) => void;\n height: number;\n setHeight: (arg: number) => void;\n weight: number;\n setWeight: (arg: number) => void;\n};\n\nexport default function BmiCalculatorComponent({\n setPageIndex,\n setBmi,\n height,\n setHeight,\n weight,\n setWeight,\n}: BmiCalculatorComponentProps) {\n const [hideErrorMessage, setHideErrorMessage] = useState(true);\n const [heightInput, setHeightInput] = useState(\n height ? height.toString() : '',\n );\n const [weightInput, setWeightInput] = useState(\n weight ? weight.toString() : '',\n );\n\n function calculateBmiAndGoForward() {\n const h = Number(heightInput.replace(',', '.'));\n const w = Number(weightInput.replace(',', '.'));\n\n // do a quick sanity check to catch typos\n if (h < 50 || h > 272 || w > 635) {\n setHideErrorMessage(false);\n return;\n }\n\n const bmi = w / (h / 100) / (h / 100);\n\n if (!bmi || bmi === Infinity) {\n setHideErrorMessage(false);\n return;\n }\n\n setHeight(h);\n setWeight(w);\n setBmi(bmi);\n setPageIndex(1);\n }\n\n function validateAndSetValue(\n e: React.ChangeEvent,\n setValue: (arg: string) => void,\n ) {\n // allow both , and . as decimal separators\n const regex = /^\\d+[,.]?\\d*$/;\n if (e.target.value === '' || regex.test(e.target.value)) {\n setValue(e.target.value);\n }\n }\n\n return (\n <>\n
\n Udregn dit BMI\n
\n
\n SundVægt programmet hos Hejdoktor tilbydes kun til personer, der\n lider af moderat eller svær overvægt. Programmet er for dig, der\n har et BMI over 30, eller et BMI over 27 og mindst én\n vægtrelateret sygdom. Her kan du udregne dit BMI og samtidig\n tilmelde dig SundVægt forløbet.\n
\n
\n
Højde i cm
\n validateAndSetValue(e, setHeightInput)}\n />\n
Vægt i kg
\n validateAndSetValue(e, setWeightInput)}\n />\n
\n calculateBmiAndGoForward()}\n >\n Udregn BMI\n \n \n \n );\n}\n","import { useEffect } from 'react';\n\ntype BmiResultComponentProps = {\n setPageIndex: (arg: number) => void;\n bmi: number;\n height: number;\n weight: number;\n};\n\nexport default function BmiResultComponent({\n setPageIndex,\n bmi,\n height,\n weight,\n}: BmiResultComponentProps) {\n useEffect(() => {\n window.scrollTo(0, 0);\n }, []);\n\n function goBack() {\n setPageIndex(0);\n }\n\n function getPointerPosition() {\n // Note: The scale starts at 10 and goes to 40, so the range is 30\n if (bmi <= 10) {\n return '0%';\n } else if (bmi >= 40) {\n return '100%';\n } else {\n const pointerWidth = (bmi - 10) * (100 / 30);\n return pointerWidth + '%';\n }\n }\n\n function getText() {\n if (bmi < 18.5) {\n return 'Dit BMI indikerer at du er undervægtig, og du er derfor ikke egnet til medicinsk vægttab.';\n } else if (bmi < 25) {\n return 'Dit BMI indikerer at du er normalvægtig, og du er derfor ikke egnet til medicinsk vægttab.';\n } else if (bmi < 27) {\n return (\n
\n Dit BMI indikerer lettere overvægt, hvilket ikke gør dig\n egnet til medicinsk vægttab. For en yderligere forklaring\n kan du skrive til{' '}\n \n kontakt@hejdoktor.dk\n \n .\n
\n );\n } else if (bmi < 30) {\n return (\n
\n Dit BMI indikerer overvægt, og du er måske egnet til\n medicinsk vægttab. Du har mulighed for at følge Hejdoktors\n vægttabsforløb, hvis du eksempelvis har en eller flere af\n følgende vægtrelaterede lidelser og risikofaktorer.\n
    \n
  • Forhøjet blodtryk
  • \n
  • Forhøjet kolesterol
  • \n
  • Dyslipidæmi
  • \n
  • Kardiovaskulær sygdom
  • \n
  • Obstruktiv søvnapnø
  • \n
  • Vægtrelaterede smertetilstande i led
  • \n
  • Dysglykæmi (prædiabetes)
  • \n
\n Når du har tilmeldt dig forløbet, vil vores læger vurdere\n din situation. Hvis det viser sig, at du ikke er egnet, vil\n du få dine penge retur.\n
\n );\n } else {\n return 'Dit BMI indikerer svær overvægt. Du har derfor mulighed for at følge Hejdoktors vægttabsforløb.';\n }\n }\n\n return (\n <>\n
\n Dit BMI er {bmi.toFixed(1).replace('.', ',')}\n
\n
{getText()}
\n
\n \n Dit BMI\n
\n ▼\n
\n
\n {/*\n * Note: Each interval has been multiplied by (100/30) to calculate the width percentage *\n * Example (first interval): 8.5 * 3.333 = 28.33 *\n */}\n
\n
\n
\n <18,5\n
\n
\n
\n
\n
\n 18,5-25\n
\n
\n
\n
\n
\n 25-30\n
\n
\n
\n
\n
\n >30\n
\n
\n
\n
\n \n \n goBack()}\n >\n \n Tilbage til BMI-beregneren\n
\n \n );\n}\n","import { useState } from 'react';\nimport BmiCalculatorComponent from './BmiCalculatorComponent';\nimport BmiResultComponent from './BmiResultComponent';\n\nexport default function App() {\n const [pageIndex, setPageIndex] = useState(0);\n const [bmi, setBmi] = useState();\n const [height, setHeight] = useState();\n const [weight, setWeight] = useState();\n\n return (\n <>\n
\n \n {pageIndex === 0 && (\n \n )}\n {pageIndex === 1 && (\n \n )}\n
\n \n );\n}\n","import { createRoot } from 'react-dom/client';\nimport App from './App';\n\nconst root = createRoot(document.getElementById('bmi'));\n\nroot.render();\n"],"names":["BmiCalculatorComponent","setPageIndex","setBmi","height","setHeight","weight","setWeight","hideErrorMessage","setHideErrorMessage","useState","heightInput","setHeightInput","weightInput","setWeightInput","calculateBmiAndGoForward","h","w","bmi","validateAndSetValue","e","setValue","regex","jsxs","Fragment","jsx","BmiResultComponent","useEffect","goBack","getPointerPosition","getText","App","pageIndex","root","createRoot"],"mappings":"+HAWA,SAAwBA,EAAuB,CAC3C,aAAAC,EACA,OAAAC,EACA,OAAAC,EACA,UAAAC,EACA,OAAAC,EACA,UAAAC,CACJ,EAAgC,CAC5B,KAAM,CAACC,EAAkBC,CAAmB,EAAIC,EAAAA,SAAS,EAAI,EACvD,CAACC,EAAaC,CAAc,EAAIF,EAAA,SAClCN,EAASA,EAAO,WAAa,EACjC,EACM,CAACS,EAAaC,CAAc,EAAIJ,EAAA,SAClCJ,EAASA,EAAO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