"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const en = require("../../locale/lang/en.js");
const Vue = require("vue");
const get = require("../../../../lodash-es/get.js");
const buildTranslator = (locale) => (path, option) => translate(path, option, Vue.unref(locale));
const translate = (path, option, locale) => get.default(locale, path, path).replace(/\{(\w+)\}/g, (_, key) => `${(option == null ? void 0 : option[key]) ?? `{${key}}`}`);
const buildLocaleContext = (locale) => {
  return {
    lang: Vue.computed(() => Vue.unref(locale).name),
    locale: Vue.isRef(locale) ? locale : Vue.ref(locale),
    t: buildTranslator(locale)
  };
};
const localeContextKey = Symbol("localeContextKey");
const useLocale = (localeOverrides) => {
  const locale = localeOverrides || Vue.inject(localeContextKey, Vue.ref());
  return buildLocaleContext(Vue.computed(() => locale.value || en.default));
};
exports.buildLocaleContext = buildLocaleContext;
exports.buildTranslator = buildTranslator;
exports.localeContextKey = localeContextKey;
exports.translate = translate;
exports.useLocale = useLocale;
