import { locales_exports } from "../types/dist/esm/locales.mjs";

//#region ../core/dist/esm/utils/intl.mjs
const cacheKey = (locales, options) => JSON.stringify([locales, options]);
const createCachedConstructor = (Ctor) => {
	const cache = /* @__PURE__ */ new Map();
	function Wrapped(locales, options) {
		if (Ctor.name === "DisplayNames" && typeof Intl?.DisplayNames !== "function") {
			console.warn([
				`// Intl.DisplayNames is not supported; falling back to raw locale (${locales}). `,
				`// Consider adding a polyfill as https://formatjs.io/docs/polyfills/intl-displaynames/`,
				``,
				`import 'intl';`,
				`import '@formatjs/intl-getcanonicallocales/polyfill';`,
				`import '@formatjs/intl-locale/polyfill';`,
				`import '@formatjs/intl-pluralrules/polyfill';`,
				`import '@formatjs/intl-displaynames/polyfill';`,
				`import '@formatjs/intl-listformat/polyfill';`,
				`import '@formatjs/intl-numberformat/polyfill';`,
				`import '@formatjs/intl-relativetimeformat/polyfill';`,
				`import '@formatjs/intl-datetimeformat/polyfill';`,
				``,
				`// Optionally add locale data`,
				`import '@formatjs/intl-pluralrules/locale-data/fr';`,
				`import '@formatjs/intl-numberformat/locale-data/fr';`,
				`import '@formatjs/intl-datetimeformat/locale-data/fr';`
			].join("\n"));
			return locales;
		}
		const key = cacheKey(locales ?? locales_exports.ENGLISH, options);
		let instance = cache.get(key);
		if (!instance) {
			instance = new Ctor(locales, options);
			cache.set(key, instance);
		}
		return instance;
	}
	Wrapped.prototype = Ctor.prototype;
	return Wrapped;
};
const createCachedIntl = () => new Proxy(Intl, { get: (target, prop, receiver) => {
	const value = Reflect.get(target, prop, receiver);
	return typeof value === "function" && /^[A-Z]/.test(String(prop)) ? createCachedConstructor(value) : value;
} });
const CachedIntl = createCachedIntl();

//#endregion
export { CachedIntl };
//# sourceMappingURL=intl.mjs.map