'use client';


const require_rolldown_runtime = require('../../../../../_virtual/rolldown_runtime.cjs');
const require_IntlayerProvider = require('../IntlayerProvider.cjs');
const require_units = require('../../@intlayer/core/dist/esm/formatters/units.cjs');
let react = require("react");

//#region ../react-intlayer/dist/esm/client/format/useUnit.mjs
/**
* React hook that provides a unit formatting function
* based on the current locale from {@link useLocaleBase}.
*
* This hook wraps {@link createUnit} to return a formatter
* that can convert values into human-readable localized units
* (e.g., "10 km", "5 lbs").
*
* @example
* ```tsx
* const formatUnit = useUnit();
* const distance = formatUnit(10, { unit: "kilometer" });
* // "10 km" (depending on locale)
* ```
*
* @returns {Function} A unit formatting function that accepts a value and optional formatting options.
*/
const useUnit = () => {
	const { locale } = (0, react.useContext)(require_IntlayerProvider.IntlayerClientContext);
	return (0, react.useCallback)((...args) => require_units.units(args[0], {
		...args[1],
		locale: args[1]?.locale ?? locale
	}), [locale]);
};

//#endregion
exports.useUnit = useUnit;
//# sourceMappingURL=useUnit.cjs.map