import localeValues from "./en_US.js";
import localeValues$1 from "./zh_CN.js";
import { computed } from "vue";
import { useConfig } from "antdv-next/config-provider/context";
//#region components/locale/useLocale.ts
function normalizeLocaleCode(locale) {
	return String(locale ?? "").toLowerCase().replace("_", "-");
}
function getDefaultLocaleByCode(localeCode) {
	return localeCode.startsWith("zh") ? localeValues$1 : localeValues;
}
function useLocale(componentName, defaultLocale) {
	const configCtx = useConfig();
	const fullLocale = computed(() => {
		return configCtx.value.locale ?? {};
	});
	return [computed(() => {
		const mergedDefaultLocale = getDefaultLocaleByCode(normalizeLocaleCode(fullLocale.value.locale))[componentName] ?? defaultLocale ?? localeValues[componentName];
		const localeFromContext = fullLocale.value?.[componentName] ?? {};
		return {
			...mergedDefaultLocale,
			...localeFromContext
		};
	}), computed(() => {
		return fullLocale.value?.locale || localeValues.locale;
	})];
}
//#endregion
export { useLocale as default };
