"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.PageEditor = void 0;
var _react = _interopRequireDefault(require("react"));
var _svg = _interopRequireDefault(require("@teamix/svg"));
var _utils = require("@teamix/utils");
var _playground = require("./playground");
var _ = require(".");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var cls = (0, _utils.usePrefixCls)('teamix-pro-pager');
var PageEditor = function PageEditor(props) {
  var type = props.type,
    initialValues = props.initialValues,
    field = props.field,
    configuratorMap = props.configuratorMap,
    pageMap = props.pageMap,
    pageDefaultInitialValues = props.pageDefaultInitialValues;
  var values = initialValues || _.PageDefaultInitialValues[type] || (pageDefaultInitialValues === null || pageDefaultInitialValues === void 0 ? void 0 : pageDefaultInitialValues[type]);
  _react.default.useEffect(function () {
    field && field.setValues(values);
  }, []);
  var onValuesChange = function onValuesChange(values) {
    field && field.setValues(values);
  };
  var Page = _.PageMap[type] || (pageMap === null || pageMap === void 0 ? void 0 : pageMap[type]);
  if (!Page) {
    return /*#__PURE__*/_react.default.createElement("div", {
      className: cls('empty')
    }, /*#__PURE__*/_react.default.createElement(_svg.default.Status404, {
      width: 160,
      height: 160
    }), /*#__PURE__*/_react.default.createElement("p", null, "\u9519\u8BEF\u7684\u9875\u9762\u7C7B\u578B"));
  }
  return /*#__PURE__*/_react.default.createElement(_playground.PagePlayground, {
    page: Page,
    initialValues: values,
    onValuesChange: onValuesChange,
    configuratorMap: configuratorMap
  });
};
exports.PageEditor = PageEditor;