{"version":3,"file":"price.cjs","names":[],"sources":["../src/price/format-price.ts"],"sourcesContent":["export interface PriceFormatOptions\n  extends Partial<Omit<Intl.NumberFormatOptions, 'currency'>> {\n  withoutSymbol?: boolean;\n  customSymbol?: string;\n}\n\n/**\n * Formats a numeric price using locale and currency options.\n *\n * @example\n * ```ts\n * formatPrice(1990, 'ru-RU', 'RUB');\n * ```\n */\nexport const formatPrice = (\n  price: number,\n  locale: string,\n  currency?: string,\n  { withoutSymbol, customSymbol, ...options }: PriceFormatOptions = {},\n) => {\n  const priceFormatter = new Intl.NumberFormat(locale, {\n    style: 'currency',\n    currency,\n    minimumFractionDigits: 0,\n    currencyDisplay: 'narrowSymbol',\n    ...options,\n  });\n\n  const zeroPrice = priceFormatter.format(0);\n  const currencySymbol = zeroPrice.replace('0', '');\n  const rawPrice = priceFormatter.format(price);\n  const priceWithoutCurrency = rawPrice.replace(currencySymbol, '');\n\n  if (withoutSymbol) {\n    return priceWithoutCurrency;\n  }\n\n  return `${priceWithoutCurrency} ${\n    customSymbol ?? (currency === 'RUB' ? 'р' : currencySymbol)\n  }`.replace(/\\s{2,}/, ' ');\n};\n"],"mappings":";;;;;;;;;;AAcA,IAAa,eACX,OACA,QACA,UACA,EAAE,eAAe,cAAc,GAAG,YAAgC,CAAC,MAChE;CACH,MAAM,iBAAiB,IAAI,KAAK,aAAa,QAAQ;EACnD,OAAO;EACP;EACA,uBAAuB;EACvB,iBAAiB;EACjB,GAAG;CACL,CAAC;CAGD,MAAM,iBADY,eAAe,OAAO,CACjB,EAAU,QAAQ,KAAK,EAAE;CAEhD,MAAM,uBADW,eAAe,OAAO,KACV,EAAS,QAAQ,gBAAgB,EAAE;CAEhE,IAAI,eACF,OAAO;CAGT,OAAO,GAAG,qBAAqB,GAC7B,iBAAiB,aAAa,QAAQ,MAAM,kBAC3C,QAAQ,UAAU,GAAG;AAC1B"}