/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var VueCompositionAPI = require('@vue/composition-api');
var components_configProvider_context = require('./context.js');
require('lodash');
require('../../chunks/zh_CN.js');

const t = function (pattern) {
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
    args[_key - 1] = arguments[_key];
  }
  const [data] = args;
  if (typeof pattern === "string") {
    if (!data) return pattern;
    const regular = /\{\s*([\w-]+)\s*\}/g;
    const translated = pattern.replace(regular, (match, key) => {
      if (data) return String(data[key]);
      return "";
    });
    return translated;
  }
  if (typeof pattern === "function") {
    if (!args.length) return pattern(VueCompositionAPI.h);
    return pattern(...args);
  }
  return "";
};
function useConfig(componentName) {
  const injectGlobalConfig = VueCompositionAPI.inject("globalConfig", null);
  const mergedGlobalConfig = injectGlobalConfig || components_configProvider_context.defaultGlobalConfig;
  const global = VueCompositionAPI.ref(mergedGlobalConfig[componentName]);
  const classPrefix = VueCompositionAPI.ref(mergedGlobalConfig.classPrefix);
  return {
    t,
    global,
    classPrefix
  };
}
function usePrefixClass(componentName) {
  const {
    classPrefix
  } = useConfig("classPrefix");
  return VueCompositionAPI.ref(componentName ? `${classPrefix.value}-${componentName}` : classPrefix.value);
}

exports.useConfig = useConfig;
exports.usePrefixClass = usePrefixClass;
//# sourceMappingURL=useConfig.js.map
