"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const React = require("react");
const zhCN = require("../locale/zh-CN.js");
const is = require("../_util/is.js");
const util = require("./util.js");
const index = require("../Message/index.js");
const index$1 = require("../Notification/index.js");
const index$2 = require("../Empty/index.js");
const config = require("../Modal/config.js");
const context = require("../../icon/react-icon/context.js");
const omit = require("../_util/omit.js");
const useMergeProps = require("../_util/hooks/useMergeProps.js");
const emotionReactJsxRuntime_browser_esm = require("../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js");
var __assign = globalThis && globalThis.__assign || function() {
  __assign = Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];
      for (var p in s)
        if (Object.prototype.hasOwnProperty.call(s, p))
          t[p] = s[p];
    }
    return t;
  };
  return __assign.apply(this, arguments);
};
var colorList = {
  primaryColor: {
    default: "--arcoblue-6",
    hover: "--arcoblue-5",
    active: "--arcoblue-7"
  },
  successColor: {
    default: "--green-6",
    hover: "--green-5",
    active: "--green-7"
  },
  infoColor: {
    default: "--arcoblue-6",
    hover: "--arcoblue-5",
    active: "--arcoblue-7"
  },
  warningColor: {
    default: "--orangered-6",
    hover: "--orangered-5",
    active: "--orangered-7"
  },
  dangerColor: {
    default: "--red-6",
    hover: "--red-5",
    active: "--red-7"
  }
};
function setTheme(theme) {
  if (theme && is.isObject(theme)) {
    var root_1 = document.body;
    Object.keys(colorList).forEach(function(color) {
      if (theme[color]) {
        root_1.style.setProperty(colorList[color].default, util.lighten(theme[color], 0));
        if (!theme[color + "Hover"]) {
          root_1.style.setProperty(colorList[color].hover, util.lighten(theme[color], 10));
        }
        if (!theme[color + "Active"]) {
          root_1.style.setProperty(colorList[color].active, util.lighten(theme[color], -10));
        }
      }
    });
  }
}
function renderEmpty(componentName) {
  switch (componentName) {
    default:
      return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$2, {});
  }
}
var defaultProps = {
  locale: zhCN,
  prefixCls: "arco",
  getPopupContainer: function() {
    return document.body;
  },
  size: "default",
  renderEmpty,
  focusLock: {
    modal: {
      autoFocus: true
    },
    drawer: {
      autoFocus: true
    }
  }
};
var componentConfig = {};
var ConfigContext = React.createContext(__assign({
  getPrefixCls: function(componentName, customPrefix) {
    return (customPrefix || "arco") + "-" + componentName;
  }
}, defaultProps));
function ConfigProvider(baseProps) {
  var props = useMergeProps(baseProps, defaultProps, componentConfig);
  var theme = props.theme, prefixCls = props.prefixCls, children = props.children, locale = props.locale, rtl = props.rtl, _a = props.effectGlobalNotice, effectGlobalNotice = _a === void 0 ? true : _a;
  React.useEffect(function() {
    setTheme(theme);
  }, [theme]);
  React.useEffect(function() {
    if (effectGlobalNotice) {
      index.config({
        prefixCls,
        rtl
      });
      index$1.config({
        prefixCls,
        rtl
      });
    }
  }, [prefixCls, rtl, effectGlobalNotice]);
  function getPrefixCls(componentName, customPrefix) {
    return (customPrefix || prefixCls) + "-" + componentName;
  }
  var config$1 = __assign(__assign({}, omit(props, ["children"])), {
    getPrefixCls
  });
  React.useEffect(function() {
    config.setConfigProviderProps({
      locale,
      prefixCls,
      rtl
    });
  }, [locale, prefixCls]);
  var child = children;
  if (prefixCls && prefixCls !== "arco") {
    child = /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(context.IconContext.Provider, {
      value: {
        prefixCls
      },
      children
    });
  }
  return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(ConfigContext.Provider, {
    value: config$1,
    children: child
  });
}
ConfigProvider.ConfigContext = ConfigContext;
ConfigProvider.displayName = "ConfigProvider";
ConfigContext.Consumer;
exports.ConfigContext = ConfigContext;
exports.default = ConfigProvider;
//# sourceMappingURL=index.js.map
