"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;
