import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import { createElement } from 'react';
import { render } from 'react-dom';
import { defaultPlugins, defaultSetters } from 'vitis-lowcode-default-ext';
import { plugins, setters, material, project } from './shell';
import Workbench from './layout/workbench';
import { observableSkeleton, observableProject } from './shell';
import { ASSET_UPDATED } from './eventType';
import { PageComponentsSpec } from './defaultConfig/asset';
export { setters, skeleton, plugins, material, project, dragon } from './shell';
export * from './eventType';
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
  return _regeneratorRuntime.wrap(function _callee$(_context) {
    while (1) switch (_context.prev = _context.next) {
      case 0:
        material.on(ASSET_UPDATED, function (loadedPackageNames) {
          observableProject.designer.buildComponentSpecMap(loadedPackageNames);
        });
        defaultPlugins.forEach(function (defaultPlugin) {
          plugins.register(defaultPlugin);
        });
        setters.register(defaultSetters);

        // Page 组件是页面的 root，它不会显示在组件面板中
        material.addComponentSpec('Page', PageComponentsSpec);
        observableProject.designer.buildComponentSpecMap(['Page']);
      case 5:
      case "end":
        return _context.stop();
    }
  }, _callee);
}))();
export 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) {
    project.project.setSchema(options.pageSchema);
  }
  render( /*#__PURE__*/createElement(Workbench, {
    skeleton: observableSkeleton,
    project: observableProject
  }), container);
}