import React from 'react';
import { App } from 'antd';
import PisellContext, { globalConfig } from "./context";
import { useResponsive } from "../../hooks";
import useEngineContext from "../../hooks/useEngineContext";
import { setMessage } from "../pisellMessage";
import { setModal } from "../pisellModal/components/functions";
var platformMap = {
  phone: 'h5',
  pc: 'pc',
  ipad: 'ipad'
};
var PisellConfigProvider = function PisellConfigProvider(props) {
  var _context$appHelper;
  var children = props.children,
    propsPlatform = props.platform,
    propsSymbol = props.symbol,
    locale = props.locale;
  var platform = useResponsive();
  var context = useEngineContext();
  var _ref = ((_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {},
    getSymbolic = _ref.getSymbolic;
  var config = {
    // 设置平台，如果父组件未传入，则使用响应式获取
    platform: propsPlatform || platformMap[platform],
    // 设置符号，优先使用父组件传入的，如果没有则从主项目获取
    symbol: propsSymbol || (getSymbolic === null || getSymbolic === void 0 ? void 0 : getSymbolic()) || '',
    locale: locale || 'en',
    getSymbolic: getSymbolic
  };
  var staticFunction = App.useApp();
  setMessage(staticFunction.message);
  setModal(staticFunction.modal);
  globalConfig.setConfig(config);
  return /*#__PURE__*/React.createElement(PisellContext.Provider, {
    value: config
  }, children);
};
export default PisellConfigProvider;