{"version":3,"names":["FORMATTER_CACHE","Map","getFormatter","locale","options","key","JSON","stringify","cached","get","formatter","Intl","NumberFormat","set","formatNumber","value","format","Number","isNaN","formatNumberMaxPrecision","nextFormat","maximumFractionDigits"],"sources":["format-number.ts"],"sourcesContent":["/**\n * Number formatting helpers used by `<NumberField.Root>` and `<NumberField.Input>`.\n *\n * Mirrors `packages/react/src/utils/formatNumber.ts`. A module-scope cache\n * keyed by `(locale, options)` keeps repeated formats cheap — constructing\n * `Intl.NumberFormat` dominates the cost.\n */\n\nconst FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\n\nexport function getFormatter(\n\tlocale?: Intl.LocalesArgument,\n\toptions?: Intl.NumberFormatOptions,\n): Intl.NumberFormat {\n\tconst key = JSON.stringify({ locale, options });\n\tconst cached = FORMATTER_CACHE.get(key);\n\tif (cached) return cached;\n\tconst formatter = new Intl.NumberFormat(locale, options);\n\tFORMATTER_CACHE.set(key, formatter);\n\treturn formatter;\n}\n\n/**\n * Formats `value` with `Intl.NumberFormat(locale, format)`. Returns the\n * empty string when `value` is `null` or non-finite so the visible `<input>`\n * can clear cleanly.\n */\nexport function formatNumber(\n\tvalue: number | null,\n\tlocale?: Intl.LocalesArgument,\n\tformat?: Intl.NumberFormatOptions,\n): string {\n\tif (value == null || Number.isNaN(value)) return \"\";\n\treturn getFormatter(locale, format).format(value);\n}\n\n/**\n * Like {@link formatNumber} but forces maximum precision (20 fraction\n * digits) when the caller didn't pin an explicit precision. Used for\n * controlled-input display where the consumer's `value` prop must round-trip\n * through the formatter without losing digits.\n */\nexport function formatNumberMaxPrecision(\n\tvalue: number | null,\n\tlocale?: Intl.LocalesArgument,\n\tformat?: Intl.NumberFormatOptions,\n): string {\n\tif (value == null || Number.isNaN(value)) return \"\";\n\tconst nextFormat: Intl.NumberFormatOptions = {\n\t\t...format,\n\t\tmaximumFractionDigits: 20,\n\t};\n\treturn getFormatter(locale, nextFormat).format(value);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,eAAe,GAAG,IAAIC,GAAG,CAA4B,CAAC;AAE5D,OAAO,SAASC,YAAYA,CAC3BC,MAA6B,EAC7BC,OAAkC,EACd;EACpB,MAAMC,GAAG,GAAGC,IAAI,CAACC,SAAS,CAAC;IAAEJ,MAAM;IAAEC;EAAQ,CAAC,CAAC;EAC/C,MAAMI,MAAM,GAAGR,eAAe,CAACS,GAAG,CAACJ,GAAG,CAAC;EACvC,IAAIG,MAAM,EAAE,OAAOA,MAAM;EACzB,MAAME,SAAS,GAAG,IAAIC,IAAI,CAACC,YAAY,CAACT,MAAM,EAAEC,OAAO,CAAC;EACxDJ,eAAe,CAACa,GAAG,CAACR,GAAG,EAAEK,SAAS,CAAC;EACnC,OAAOA,SAAS;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,YAAYA,CAC3BC,KAAoB,EACpBZ,MAA6B,EAC7Ba,MAAiC,EACxB;EACT,IAAID,KAAK,IAAI,IAAI,IAAIE,MAAM,CAACC,KAAK,CAACH,KAAK,CAAC,EAAE,OAAO,EAAE;EACnD,OAAOb,YAAY,CAACC,MAAM,EAAEa,MAAM,CAAC,CAACA,MAAM,CAACD,KAAK,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,wBAAwBA,CACvCJ,KAAoB,EACpBZ,MAA6B,EAC7Ba,MAAiC,EACxB;EACT,IAAID,KAAK,IAAI,IAAI,IAAIE,MAAM,CAACC,KAAK,CAACH,KAAK,CAAC,EAAE,OAAO,EAAE;EACnD,MAAMK,UAAoC,GAAG;IAC5C,GAAGJ,MAAM;IACTK,qBAAqB,EAAE;EACxB,CAAC;EACD,OAAOnB,YAAY,CAACC,MAAM,EAAEiB,UAAU,CAAC,CAACJ,MAAM,CAACD,KAAK,CAAC;AACtD","ignoreList":[]}