'use strict';

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

var vue = require('vue');
var config = require('../../../locale/config.js');
require('../../../utils/index.js');
var antDesignVue = require('ant-design-vue');
var dayjs = require('dayjs');
var configProvider = require('./config-provider.js');
var hooks = require('./hooks.js');
var lodashEs = require('lodash-es');
var createNamespace = require('../../../utils/create-namespace.js');

"use strict";
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...{
    name: "LlConfigProvider"
  },
  __name: "config-provider",
  props: configProvider.configProviderProps,
  setup(__props) {
    const attrs = vue.useAttrs();
    const props = __props;
    const { provideGlobalConfig, setTheme } = hooks.useConfigProvider();
    const { defaultAlgorithm } = antDesignVue.theme;
    const antLocale = vue.computed(() => {
      const locale = props.locale;
      if (locale && locale.name) {
        const newLocale = config.ANT_LOCALE_LIST.find(
          (item) => item.name === locale.name
        );
        dayjs.locale(locale.name);
        return newLocale.locale;
      }
      dayjs.locale(config.DEFAULT_LOCALE);
      return null;
    });
    const theme = vue.computed(() => {
      if (props.theme && lodashEs.isObject(props.theme)) {
        const {
          type = configProvider.DEFAULT_THEME_MODE,
          inherit = true,
          components,
          extraToken = {}
        } = props.theme;
        props.theme.extraToken;
        let { token, algorithm = defaultAlgorithm } = props.theme;
        token = { ...extraToken };
        if (type && configProvider.THEME_ENUM[type]) {
          const storageTheme = type || configProvider.DEFAULT_THEME_MODE;
          const themeToken = setTheme(storageTheme);
          algorithm = themeToken.algorithm;
          token = { ...themeToken.token, ...extraToken };
        }
        return {
          token,
          inherit,
          algorithm,
          components
        };
      }
      return {};
    });
    const bem = createNamespace.createNamespace("config-provider");
    provideGlobalConfig(vue.computed(() => props));
    return (_ctx, _cache) => {
      const _component_a_config_provider = vue.resolveComponent("a-config-provider");
      return vue.openBlock(), vue.createBlock(_component_a_config_provider, vue.mergeProps({
        class: vue.unref(bem).b()
      }, vue.unref(attrs), {
        theme: theme.value,
        "auto-insert-space-in-button": _ctx.autoInsertSpaceInButton,
        "component-size": _ctx.componentSize,
        locale: antLocale.value
      }), {
        default: vue.withCtx(() => [
          vue.createCommentVNode(" \u9ED8\u8BA4\u63D2\u69FD "),
          vue.renderSlot(_ctx.$slots, "default"),
          vue.createCommentVNode(" \u81EA\u5B9A\u4E49\u7A7A\u6570\u636E "),
          vue.renderSlot(_ctx.$slots, "renderEmpty")
        ]),
        _: 3
        /* FORWARDED */
      }, 16, ["class", "theme", "auto-insert-space-in-button", "component-size", "locale"]);
    };
  }
});

exports.default = _sfc_main;
//# sourceMappingURL=config-provider.vue2.js.map
