{ "version": 3, "sources": ["src/app/_pipes/compact-number.pipe.ts"], "sourcesContent": ["import { Pipe, PipeTransform } from '@angular/core';\r\nimport {AccountService} from \"../_services/account.service\";\r\n\r\nconst specialCases = [4, 7, 10, 13];\r\n\r\n@Pipe({\r\n name: 'compactNumber',\r\n standalone: true\r\n})\r\nexport class CompactNumberPipe implements PipeTransform {\r\n\r\n constructor() {}\r\n\r\n transform(value: number): string {\r\n // Weblate allows some non-standard languages, like 'zh_Hans', which should be just 'zh'. So we handle that here\r\n const key = localStorage.getItem(AccountService.localeKey)?.replace('_', '-');\r\n if (key?.endsWith('Hans')) {\r\n return this.transformValue(key?.split('-')[0] || 'en', value);\r\n }\r\n return this.transformValue(key || 'en', value);\r\n }\r\n\r\n private transformValue(locale: string, value: number) {\r\n const formatter = new Intl.NumberFormat(locale, {\r\n //@ts-ignore\r\n notation: 'compact', // https://github.com/microsoft/TypeScript/issues/36533\r\n maximumSignificantDigits: 3\r\n });\r\n\r\n const formatterForDoublePrecision = new Intl.NumberFormat(locale, {\r\n //@ts-ignore\r\n notation: 'compact', // https://github.com/microsoft/TypeScript/issues/36533\r\n maximumSignificantDigits: 2\r\n });\r\n\r\n if (value < 1000) return value + '';\r\n if (specialCases.includes((value + '').length)) { // from 4, every 3 will have a case where we need to override\r\n return formatterForDoublePrecision.format(value);\r\n }\r\n\r\n return formatter.format(value);\r\n }\r\n\r\n\r\n\r\n}\r\n"], "mappings": "iFAGA,IAAMA,EAAe,CAAC,EAAG,EAAG,GAAI,EAAE,EAMrBC,GAAiB,IAAA,CAAxB,MAAOA,CAAiB,CAE5BC,aAAA,CAAe,CAEfC,UAAUC,EAAa,CAErB,IAAMC,EAAMC,aAAaC,QAAQC,EAAeC,SAAS,GAAGC,QAAQ,IAAK,GAAG,EAC5E,OAAIL,GAAKM,SAAS,MAAM,EACf,KAAKC,eAAeP,GAAKQ,MAAM,GAAG,EAAE,CAAC,GAAK,KAAMT,CAAK,EAEvD,KAAKQ,eAAeP,GAAO,KAAMD,CAAK,CAC/C,CAEQQ,eAAeE,EAAgBV,EAAa,CAClD,IAAMW,EAAY,IAAIC,KAAKC,aAAaH,EAAQ,CAE9CI,SAAU,UACVC,yBAA0B,EAC3B,EAEKC,EAA8B,IAAIJ,KAAKC,aAAaH,EAAQ,CAEhEI,SAAU,UACVC,yBAA0B,EAC3B,EAED,OAAIf,EAAQ,IAAaA,EAAQ,GAC7BJ,EAAaqB,UAAUjB,EAAQ,IAAIkB,MAAM,EACpCF,EAA4BG,OAAOnB,CAAK,EAG1CW,EAAUQ,OAAOnB,CAAK,CAC/B,iDAhCWH,EAAiB,CAAA,qDAAjBA,EAAiBuB,KAAA,GAAAC,WAAA,EAAA,CAAA,CAAA,SAAjBxB,CAAiB,GAAA", "names": ["specialCases", "CompactNumberPipe", "constructor", "transform", "value", "key", "localStorage", "getItem", "AccountService", "localeKey", "replace", "endsWith", "transformValue", "split", "locale", "formatter", "Intl", "NumberFormat", "notation", "maximumSignificantDigits", "formatterForDoublePrecision", "includes", "length", "format", "pure", "standalone"] }