{"version":3,"sources":["../../../../src/server/format/usePercentage.ts"],"sourcesContent":["import { type LocalesValues } from '@intlayer/config/client';\nimport { percentage } from '@intlayer/core';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React hook to provide a percentage formatter function\n * based on the current application locale.\n *\n * This hook retrieves the active locale using {@link useLocaleBase}\n * and memoizes a `createPercentage` instance for that locale.\n *\n * @example\n * ```tsx\n * const formatPercentage = usePercentage();\n *\n * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });\n * // \"87.5%\" (depending on locale)\n * ```\n *\n * @returns {(value: string | number, options?: Omit<PercentageOptions, \"value\">) => string}\n * A function that formats numbers or numeric strings into localized percentages.\n */\nexport const usePercentage = () => {\n  const locale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n  return (...args: Parameters<typeof percentage>) =>\n    percentage(args[0], {\n      ...args[1],\n      locale: args[1]?.locale ?? locale,\n    });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAA2B;AAC3B,oCAAsC;AACtC,2BAAiC;AAoB1B,MAAM,gBAAgB,MAAM;AACjC,QAAM,aAAS,uCAAgC,mDAAqB;AAEpE,SAAO,IAAI,aACT,wBAAW,KAAK,CAAC,GAAG;AAAA,IAClB,GAAG,KAAK,CAAC;AAAA,IACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,EAC7B,CAAC;AACL;","names":[]}