const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
let __intlayer_config_built = require("@intlayer/config/built");
__intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
let __intlayer_core = require("@intlayer/core");
let __intlayer_types = require("@intlayer/types");
let next_headers_js = require("next/headers.js");

//#region src/server/getLocale.ts
const getLocale = async () => {
	const defaultLocale = __intlayer_config_built.default?.internationalization?.defaultLocale ?? __intlayer_types.Locales.ENGLISH;
	const headersList = await (0, next_headers_js.headers)();
	const cookiesList = await (0, next_headers_js.cookies)();
	const storedLocale = (0, __intlayer_core.getLocaleFromStorage)({
		getCookie: (name) => cookiesList.get(name)?.value ?? null,
		getHeader: (name) => headersList.get(name) ?? null
	});
	if (storedLocale) return storedLocale;
	const negotiatorHeaders = {};
	headersList.forEach((value, key) => {
		negotiatorHeaders[key] = value;
	});
	const userFallbackLocale = (0, __intlayer_core.localeDetector)(negotiatorHeaders);
	if (userFallbackLocale) return userFallbackLocale;
	return defaultLocale;
};

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