{"version":3,"file":"units.mjs","names":[],"sources":["../../../src/formatters/units.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getCachedIntl } from '../utils/intl';\n\n/**\n * Formats a numeric value as a localized unit string.\n *\n * @example\n * units(5, { unit: \"kilometer\", unitDisplay: \"long\", locale: \"en-GB\" });\n * // \"5 kilometers\"\n */\nexport const units = (\n  value: number | string,\n  options?: Intl.NumberFormatOptions & { locale?: LocalesValues }\n): string =>\n  getCachedIntl(\n    Intl.NumberFormat,\n    options?.locale ?? internationalization?.defaultLocale,\n\n    {\n      style: 'unit',\n      unit: options?.unit ?? 'day',\n      unitDisplay: options?.unitDisplay ?? 'short',\n      useGrouping: options?.useGrouping ?? false,\n    }\n  ).format(Number(value));\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,SACX,OACA,YAEA,cACE,KAAK,cACL,SAAS,UAAU,sBAAsB,eAEzC;CACE,OAAO;CACP,MAAM,SAAS,QAAQ;CACvB,aAAa,SAAS,eAAe;CACrC,aAAa,SAAS,eAAe;CACtC,CACF,CAAC,OAAO,OAAO,MAAM,CAAC"}