function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

/* eslint-disable */
import React from 'react';
/**
 * TODO: 为了让移动端渲染器不依赖PC端组件库，RendererBox 需要分成两种实现：PCRenderer, PhoneRenderer，同时清理组件依赖关系，保证不同的业务工程打出来的包体积最小。
 * @class DesignerBox 渲染态。
 *
 * MagicBox 在 designer 模式和 renderer 模式下具有不同的外观和功能。
 * - 在 designer 模式下，具有拖拽布局功能。
 * - 在 renderer 模式下纯展现，其功能退化成一层空的容器 div，不再具有设计器功能。
 * 分成2个内部组件分别实现设计器和渲染器功能：DesignerBox 和 RendererBox。
 *
 * @author zhang.xiaofei38@iwhalecloud.com
 */

var RendererBox = function RendererBox(_ref) {
  var id = _ref.id,
      pid = _ref.pid,
      index = _ref.index,
      nodeData = _ref.nodeData,
      children = _ref.children,
      componentMap = _ref.componentMap,
      _ref$style = _ref.style,
      style = _ref$style === void 0 ? {} : _ref$style,
      className = _ref.className,
      _ref$mode = _ref.mode,
      mode = _ref$mode === void 0 ? 'renderer' : _ref$mode,
      terminalType = _ref.terminalType,
      spacing = _ref.spacing;
  var temp = /*#__PURE__*/React.createElement(React.Fragment, null, children, nodeData && nodeData.childNodes && nodeData.childNodes.map(function (nodeData, index) {
    var Clazz = componentMap[nodeData.type];

    if (!Clazz) {
      console.error("[MagicBox] Can not find type ".concat(nodeData.type));
      return;
    }

    nodeData.index = index;

    var newInstanceProps = _objectSpread({}, nodeData, {
      nodeData: nodeData,
      componentMap: componentMap,
      mode: mode,
      terminalType: terminalType,
      canDrag: false
    });

    var Component = React.createElement(Clazz, _objectSpread({}, newInstanceProps), null);

    if (nodeData.type === "MRecommend") {
      var comp = React.lazy(function () {
        return import('../MComponents/mobile/MRecommend');
      });
    }

    return /*#__PURE__*/React.createElement(React.Fragment, {
      key: nodeData.id
    }, /*#__PURE__*/React.createElement("div", {
      style: {
        paddingBottom: spacing
      }
    }, Component));
  }));
  return /*#__PURE__*/React.createElement("div", {
    style: _objectSpread({
      width: '100%',
      height: '100%'
    }, style),
    className: className || ''
  }, className === 'mrow-renderer' ? /*#__PURE__*/React.createElement("div", {
    style: {
      display: 'flex',
      width: window.safeArea
    }
  }, temp) : /*#__PURE__*/React.createElement(React.Fragment, null, temp));
};

export default RendererBox;