{ "version": 3, "sources": ["../../../../../../owl-nest/common/money/src/money.ts"], "sourcesContent": ["const formatterCache: Record = {}\n\ntype FormatterConfig = {\n currency?: string\n locale?: string\n}\n\nconst DEFAULT_FORMATTER_CONFIG: FormatterConfig = {\n currency: 'EUR',\n locale: 'fr-FR',\n}\n\nexport function format(\n amount: number,\n { currency = DEFAULT_FORMATTER_CONFIG.currency, locale = DEFAULT_FORMATTER_CONFIG.locale }: FormatterConfig = {},\n): string {\n return getFormatter({ locale, currency })\n .format(amount)\n .replace(/([.,])00/g, '')\n}\n\nfunction getFormatter(config: FormatterConfig): Intl.NumberFormat {\n const cacheKey = `${config.currency}-${config.locale}`\n\n if (formatterCache[cacheKey] === undefined) {\n formatterCache[cacheKey] = new Intl.NumberFormat(config.locale, {\n currency: config.currency,\n style: 'currency',\n })\n }\n return formatterCache[cacheKey]\n}\n\ntype RangeFormatterConfig = FormatterConfig & { rangeString?: (minPriceString: string) => string }\n\nexport function formatRange(\n range: [number, number],\n {\n currency = DEFAULT_FORMATTER_CONFIG.currency,\n locale = DEFAULT_FORMATTER_CONFIG.locale,\n rangeString = (minPriceString: string) => {\n return `d\u00E8s ${minPriceString}`\n },\n }: RangeFormatterConfig = {},\n): string {\n return range[0] === range[1]\n ? `${format(range[0], { currency, locale })}`\n : rangeString(format(range[0], { currency, locale }))\n}\n\ntype DiscountFormatterConfig = FormatterConfig & { freeProductString?: string }\nexport function formatDiscount(\n amount: number,\n {\n currency = DEFAULT_FORMATTER_CONFIG.currency,\n freeProductString = 'Gratuit',\n locale = DEFAULT_FORMATTER_CONFIG.locale,\n }: DiscountFormatterConfig = {},\n): string {\n if (amount === 0) {\n return freeProductString\n }\n return format(amount, { currency, locale })\n}\n"], "mappings": "iDAAAA,IAAAC,IAAA,IAAMC,EAAoD,CAAC,EAOrDC,EAA4C,CAChD,SAAU,MACV,OAAQ,OACV,EAEO,SAASC,EACdC,EACA,CAAE,SAAAC,EAAWH,EAAyB,SAAU,OAAAI,EAASJ,EAAyB,MAAO,EAAqB,CAAC,EACvG,CACR,OAAOK,EAAa,CAAE,OAAAD,EAAQ,SAAAD,CAAS,CAAC,EACrC,OAAOD,CAAM,EACb,QAAQ,YAAa,EAAE,CAC5B,CAEA,SAASG,EAAaC,EAA4C,CAChE,IAAMC,EAAW,GAAG,OAAAD,EAAO,SAAQ,KAAI,OAAAA,EAAO,QAE9C,OAAIP,EAAeQ,CAAQ,IAAM,SAC/BR,EAAeQ,CAAQ,EAAI,IAAI,KAAK,aAAaD,EAAO,OAAQ,CAC9D,SAAUA,EAAO,SACjB,MAAO,UACT,CAAC,GAEIP,EAAeQ,CAAQ,CAChC", "names": ["init_define_process_env", "init_sentry_release_injection_stub", "formatterCache", "DEFAULT_FORMATTER_CONFIG", "format", "amount", "currency", "locale", "getFormatter", "config", "cacheKey"] }