{"version":3,"file":"FormattedNumber.jsx","names":["memo","FormattedNumber","formatter","Intl","NumberFormat","value","compact","formatCompact","format","n","Math","abs"],"sources":["../src/FormattedNumber.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nexport interface FormattedNumberProps {\n\t/** Value to format. */\n\tvalue: number;\n\t/** Whether to shorten the number if it gets too big. For example, \"9k\" instead of \"9.231\". */\n\tcompact?: boolean;\n}\n\nexport default memo(FormattedNumber);\n\nconst formatter = new Intl.NumberFormat(\"de\");\n\nfunction FormattedNumber({ value, compact }: FormattedNumberProps) {\n\treturn compact ? formatCompact(value) : formatter.format(value);\n}\n\n/**\n * We could use `Intl.NumberFormat(\"de\", { notation: \"compact\" })`,\n * but it uses \"15 Mio.\" for the short form and doesn't shorten 1000 to 1k.\n *\n * Thats why we do it manually. Mimics \"toSiUnit\" from old frontend.\n */\nfunction formatCompact(n: number): string {\n\tif (Math.abs(n) >= 1_000_000) {\n\t\treturn `${(n / 1_000_000) | 0}m`;\n\t}\n\tif (Math.abs(n) >= 1_000) {\n\t\treturn `${(n / 1_000) | 0}k`;\n\t}\n\treturn formatter.format(n);\n}\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,OAAO;AAS5B,eAAeA,IAAI,CAACC,eAAe,CAAC;AAEpC,MAAMC,SAAS,GAAG,IAAIC,IAAI,CAACC,YAAY,CAAC,IAAI,CAAC;AAE7C,SAASH,eAAeA,CAAC;EAAEI,KAAK;EAAEC;AAA8B,CAAC,EAAE;EAClE,OAAOA,OAAO,GAAGC,aAAa,CAACF,KAAK,CAAC,GAAGH,SAAS,CAACM,MAAM,CAACH,KAAK,CAAC;AAChE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,aAAaA,CAACE,CAAS,EAAU;EACzC,IAAIC,IAAI,CAACC,GAAG,CAACF,CAAC,CAAC,IAAI,SAAS,EAAE;IAC7B,OAAO,GAAIA,CAAC,GAAG,SAAS,GAAI,CAAC,GAAG;EACjC;EACA,IAAIC,IAAI,CAACC,GAAG,CAACF,CAAC,CAAC,IAAI,KAAK,EAAE;IACzB,OAAO,GAAIA,CAAC,GAAG,KAAK,GAAI,CAAC,GAAG;EAC7B;EACA,OAAOP,SAAS,CAACM,MAAM,CAACC,CAAC,CAAC;AAC3B","ignoreList":[]}