"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
var _exportNames = {
  skeleton: true,
  dragon: true,
  init: true,
  plugins: true,
  setters: true,
  material: true,
  project: true
};
exports.dragon = void 0;
exports.init = init;
exports.skeleton = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _react = require("react");
var _reactDom = require("react-dom");
var _vitisLowcodeDefaultExt = require("vitis-lowcode-default-ext");
var _shell = require("./shell");
exports.plugins = _shell.plugins;
exports.setters = _shell.setters;
exports.material = _shell.material;
exports.project = _shell.project;
exports.skeleton = _shell.skeleton;
exports.dragon = _shell.dragon;
var _workbench = _interopRequireDefault(require("./layout/workbench"));
var _eventType = require("./eventType");
Object.keys(_eventType).forEach(function (key) {
  if (key === "default" || key === "__esModule") return;
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  if (key in exports && exports[key] === _eventType[key]) return;
  exports[key] = _eventType[key];
});
var _asset = require("./defaultConfig/asset");
(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  return _regenerator["default"].wrap(function _callee$(_context) {
    while (1) switch (_context.prev = _context.next) {
      case 0:
        _shell.material.on(_eventType.ASSET_UPDATED, function (loadedPackageNames) {
          _shell.observableProject.designer.buildComponentSpecMap(loadedPackageNames);
        });
        _vitisLowcodeDefaultExt.defaultPlugins.forEach(function (defaultPlugin) {
          _shell.plugins.register(defaultPlugin);
        });
        _shell.setters.register(_vitisLowcodeDefaultExt.defaultSetters);

        // Page 组件是页面的 root，它不会显示在组件面板中
        _shell.material.addComponentSpec('Page', _asset.PageComponentsSpec);
        _shell.observableProject.designer.buildComponentSpecMap(['Page']);
      case 5:
      case "end":
        return _context.stop();
    }
  }, _callee);
}))();
function init(container, options) {
  if (options === void 0) {
    options = {};
  }
  if (!container) {
    container = document.createElement('div');
    container.id = 'vitis-engine';
    document.body.appendChild(container);
  }
  if (options.pageSchema) {
    _shell.project.project.setSchema(options.pageSchema);
  }
  (0, _reactDom.render)( /*#__PURE__*/(0, _react.createElement)(_workbench["default"], {
    skeleton: _shell.observableSkeleton,
    project: _shell.observableProject
  }), container);
}