"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    useApI18n: ()=>useApI18n,
    ApI18nProvider: ()=>ApI18nProvider,
    SUPPORTED_LOCALES: ()=>SUPPORTED_LOCALES
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const core_namespaceObject = require("@lingui/core");
const react_namespaceObject = require("@lingui/react");
const external_react_namespaceObject = require("react");
const external_locale_registry_cjs_namespaceObject = require("./locale-registry.cjs");
const SUPPORTED_LOCALES = [
    'en',
    'es',
    'pt',
    'de',
    'fr',
    'ja',
    'ko',
    'ru',
    'tr',
    'zh-CN',
    'zh-TW',
    'pt-BR',
    'es-MX'
];
function ApI18nProvider({ component, locale: propLocale, children }) {
    const detectedLang = document.documentElement.lang;
    const fallback = SUPPORTED_LOCALES.includes(detectedLang) ? detectedLang : 'en';
    const locale = propLocale || fallback;
    const loadAndActivate = (0, external_react_namespaceObject.useCallback)(()=>{
        const preImportedLocales = (0, external_locale_registry_cjs_namespaceObject.getAllPreImportedLocales)(component);
        if (!preImportedLocales) {
            console.error(`No locales found for component: ${component}`);
            core_namespaceObject.i18n.load(locale, {});
            core_namespaceObject.i18n.activate(locale);
            return;
        }
        SUPPORTED_LOCALES.forEach((supportedLocale)=>{
            const messages = preImportedLocales[supportedLocale];
            if (messages) core_namespaceObject.i18n.load(supportedLocale, messages);
        });
        core_namespaceObject.i18n.activate(locale);
    }, [
        component,
        locale
    ]);
    (0, external_react_namespaceObject.useEffect)(()=>{
        loadAndActivate();
    }, [
        loadAndActivate
    ]);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.I18nProvider, {
        i18n: core_namespaceObject.i18n,
        children: children
    });
}
function useApI18n() {
    return core_namespaceObject.i18n;
}
exports.ApI18nProvider = __webpack_exports__.ApI18nProvider;
exports.SUPPORTED_LOCALES = __webpack_exports__.SUPPORTED_LOCALES;
exports.useApI18n = __webpack_exports__.useApI18n;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "ApI18nProvider",
    "SUPPORTED_LOCALES",
    "useApI18n"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
