var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/page/index.tsx
var page_exports = {};
__export(page_exports, {
  default: () => page_default
});
module.exports = __toCommonJS(page_exports);
var import_react = __toESM(require("react"));
var import_config_provider = __toESM(require("../config-provider"));
var import_AdapterDayjs = require("@pisell/date-picker/es/AdapterDayjs");
var import_VariablesProvider = __toESM(require("../dataSourceComponents/provider/variables/VariablesProvider"));
var import_date_picker = require("@pisell/date-picker");
var import_antd = require("antd");
var import_en_US = __toESM(require("antd/es/locale/en_US"));
var import_zh_CN = __toESM(require("antd/es/locale/zh_CN"));
var import_zh_TW = __toESM(require("antd/es/locale/zh_TW"));
var import_zh_HK = __toESM(require("antd/es/locale/zh_HK"));
var import_ja_JP = __toESM(require("antd/es/locale/ja_JP"));
var import_pt_PT = __toESM(require("antd/es/locale/pt_PT"));
var import_pisell_config_provider = __toESM(require("../pisell-config-provider"));
var import_useEngineContext = __toESM(require("../../hooks/useEngineContext"));
var import_tokens = require("../../theme/tokens");
var localMap = {
  "zh-TW": import_zh_TW.default,
  "zh-CN": import_zh_CN.default,
  "zh-HK": import_zh_HK.default,
  "en-US": import_en_US.default,
  en: import_en_US.default,
  "ja": import_ja_JP.default,
  "pt": import_pt_PT.default
};
var localeDateMap = {
  "en-US": {
    adapterLocale: "en"
  },
  en: {
    adapterLocale: "en"
  },
  "zh-TW": {
    adapterLocale: "zh-tw"
  },
  "zh-HK": {
    adapterLocale: "zh-tw"
  },
  "zh-CN": {
    adapterLocale: "zh-cn"
  },
  "ja": {
    adapterLocale: "ja"
  },
  "pt": {
    adapterLocale: "pt"
  }
};
var Page = (props) => {
  var _a, _b, _c, _d, _e, _f;
  const { children, style, className, locale: propsLocale, variablesConfig, isRenderPisellConfigProvider = true, ...others } = props;
  const context = (0, import_useEngineContext.default)();
  const { platform, themeColor } = ((_a = context.appHelper) == null ? void 0 : _a.constants) || {};
  const locale = propsLocale || ((_c = (_b = context == null ? void 0 : context.engine) == null ? void 0 : _b.props) == null ? void 0 : _c.locale) || "en";
  const theme = (0, import_react.useMemo)(() => {
    var _a2, _b2;
    if (props == null ? void 0 : props.theme) {
      return {
        ...props.theme,
        token: {
          ...props.theme.token,
          // 外部透传主题时，如果没有传入colorPrimary 默认使用主项目内主题色
          colorPrimary: ((_b2 = (_a2 = props == null ? void 0 : props.theme) == null ? void 0 : _a2.token) == null ? void 0 : _b2.colorPrimary) || themeColor || "#5D3F9F"
        }
      };
    }
    return (0, import_tokens.getThemeConfig)(themeColor);
  }, [themeColor, props == null ? void 0 : props.theme]);
  const datePickerTheme = (0, import_react.useMemo)(() => {
    var _a2;
    return (0, import_date_picker.createTheme)({
      palette: {
        primary: { main: ((_a2 = theme.token) == null ? void 0 : _a2.colorPrimary) || "#5D3F9F" }
      }
    });
  }, [platform, themeColor]);
  const PisellConfigProvid = isRenderPisellConfigProvider ? import_pisell_config_provider.default : import_react.default.Fragment;
  (0, import_react.useEffect)(() => {
    document.body.id = "body";
  }, []);
  return /* @__PURE__ */ import_react.default.createElement(
    import_config_provider.default,
    {
      ...others,
      locale: localMap[locale],
      prefixCls: props.prefixCls || "pisell-lowcode",
      theme
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_antd.App,
      {
        component: false,
        message: {
          maxCount: 1
        }
      },
      /* @__PURE__ */ import_react.default.createElement(
        import_date_picker.LocalizationProvider,
        {
          dateAdapter: import_AdapterDayjs.AdapterDayjs,
          adapterLocale: ((_d = localeDateMap == null ? void 0 : localeDateMap[locale]) == null ? void 0 : _d.adapterLocale) || "en"
        },
        /* @__PURE__ */ import_react.default.createElement(import_date_picker.ThemeProvider, { theme: datePickerTheme }, /* @__PURE__ */ import_react.default.createElement(import_date_picker.LocaleProvider, { value: { locale } }, /* @__PURE__ */ import_react.default.createElement(PisellConfigProvid, { locale }, /* @__PURE__ */ import_react.default.createElement(
          import_VariablesProvider.default,
          {
            variables: ((_f = (_e = context.engine) == null ? void 0 : _e.props) == null ? void 0 : _f.variables) || {},
            config: variablesConfig
          },
          /* @__PURE__ */ import_react.default.createElement(
            "div",
            {
              style: {
                ...style,
                "--theme-color": themeColor || "#5D3F9F"
              },
              className
            },
            children
          )
        ))))
      )
    )
  );
};
var page_default = Page;
