{"version":3,"file":"currencyInputHelper.cjs","sources":["../../../../src/components/Input/CurrencyInput/currencyInputHelper.ts"],"sourcesContent":["export function formatCurrency(value?: string) {\n  if (!value) {\n    return ''\n  }\n  const converted = value\n    .replace(/[０-９．]/g, (s) => String.fromCharCode(s.charCodeAt(0) - 0xfee0)) // convert number and dot to half-width\n    .replace(/[−ー]/, '-') // replace full-width minus\n    .replace(/^(-?)0+(?!\\.|$)/, '$1') // remove 0 at the front of integer part\n  const nonNumericRegExp = /[^0-9.-]/g\n  if (converted.match(nonNumericRegExp) || isNaN(Number(converted))) {\n    // if value includes non-numeric characters, return value as it is\n    // otherwise, we assume `converted` contains only numeric characters\n    return value\n  }\n  const [integerPart, decimalPart] = converted.split('.')\n  const commaed = integerPart.replace(/(\\d)(?=(\\d{3})+(?!\\d))/g, '$1,') // add comma to integer every 3 digits\n  if (!decimalPart) {\n    return commaed\n  }\n  const excludedEndZero = decimalPart.replace(/0+$/, '')\n  if (excludedEndZero.length === 0) {\n    return commaed\n  }\n  return [commaed, excludedEndZero].join('.')\n}\n"],"names":[],"mappings":";;AAAM,SAAU,cAAc,CAAC,KAAc,EAAA;IAC3C,IAAI,CAAC,KAAK,EAAE;AACV,QAAA,OAAO,EAAE;IACX;IACA,MAAM,SAAS,GAAG;SACf,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;AACxE,SAAA,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;AACpB,SAAA,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAA;IACnC,MAAM,gBAAgB,GAAG,WAAW;AACpC,IAAA,IAAI,SAAS,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE;;;AAGjE,QAAA,OAAO,KAAK;IACd;AACA,IAAA,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC;AACvD,IAAA,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAA;IACrE,IAAI,CAAC,WAAW,EAAE;AAChB,QAAA,OAAO,OAAO;IAChB;IACA,MAAM,eAAe,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AACtD,IAAA,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;AAChC,QAAA,OAAO,OAAO;IAChB;IACA,OAAO,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;AAC7C;;;;"}