import { setupI18n } from "@lingui/core";
import { LinguiContext } from "@lingui/react";
import { useContext, useMemo } from "react";
const fallbackI18n = setupI18n({
    locale: 'en',
    messages: {
        en: {}
    }
});
const fallbackTranslate = (arg)=>{
    if ('string' == typeof arg) return arg;
    if (!arg.message) return arg.id;
    return fallbackI18n._(arg);
};
function useSafeLingui() {
    const ctx = useContext(LinguiContext);
    return useMemo(()=>({
            _: ctx?._ ?? fallbackTranslate
        }), [
        ctx
    ]);
}
export { useSafeLingui };
