import { isVNode as f, ref as s, defineComponent as v, computed as n, watch as C, onActivated as P, createVNode as h, renderSlot as w } from "vue";
import { ConfigProvider as T } from "@aplus-frontend/antdv";
import { merge as b, cloneDeep as A } from "lodash-unified";
import { useDevWarning as G } from "../utils/warning.mjs";
import { mergeAntdProviderConfigWithCache as l, mergeAntdProvideConfig as p } from "../utils/config-provider-preset.mjs";
import { configProviderProps as D } from "./config-provider-props.mjs";
import { DEFAULT_NAMESPACE as F } from "./constants.mjs";
import { useGlobalConfig as k, provideGlobalConfig as E } from "./hooks/use-global-config.mjs";
function M(e) {
  return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !f(e);
}
const r = s({}), _ = /* @__PURE__ */ v({
  name: "AplusConfigProvider",
  props: D(),
  setup(e, {
    slots: u
  }) {
    G("ConfigProvider")(!e.uiMode, "breaking", "uiMode has been remove, see migrate guide https://aplus.aplnk.com/aplus-ui/guide/migrate-7.2.html");
    function o(a, c) {
      return e[a] ?? i.value?.[a] ?? c;
    }
    const i = k(), g = n(() => b(A(i.value?.aplusToken || {}), e.aplusToken)), m = n(() => ({
      namespace: o("namespace", F),
      apGrid: o("apGrid"),
      agGrid: o("agGrid"),
      apProCard: o("apProCard"),
      apImage: o("apImage"),
      apTitle: o("apTitle"),
      searchForm: o("searchForm"),
      apUpload: o("apUpload"),
      apDescriptions: o("apDescriptions"),
      apFilePreview: o("apFilePreview"),
      apExportGroup: o("apExportGroup"),
      apView: o("apView"),
      aplusLocale: e.aplusLocale,
      aplusToken: g.value,
      api: e.api,
      valueTypeMap: e.valueTypeMap,
      downloadCenterTriggerConfig: e.downloadCenterTriggerConfig,
      scrollYDomName: e.scrollYDomName,
      viewCacheOption: e.viewCacheOption
    })), d = E(m);
    let t = !0;
    return C(() => e, (a) => {
      r.value = l(p(a), r.value);
    }, {
      deep: !0,
      immediate: !0
    }), P(() => {
      if (t) {
        t = !1;
        return;
      }
      r.value = l(p(e), r.value);
    }), () => {
      let a;
      return h(T, r.value, M(a = w(u, "default", {
        config: d?.value
      })) ? a : {
        default: () => [a]
      });
    };
  }
});
export {
  _ as ConfigProvider,
  r as globalConfigCached
};
