import DashboardV1 from './v1';
import DashboardV2 from './v2';

export interface DashboardType extends Object {

}

const _window = window as any;

_window.SPFrontPanel = _window.spFPanelWrapper = {
  init: ({version, ...extraOptions}: {
    version?: string
  }) => {
    const _window = window as any;

    switch (version) {
      case 'v1':
        _window.SPFrontPanel = _window.spFPanelWrapper = DashboardV1;
        // 在 window 上挂载 grapesjs 对象是兼容旧版本suanpan-web，有直接使用 grapesjs 的情况，264之后的版本应该可以删除，留作观察
        _window.grapesjs = DashboardV1.grapesjs;

        return DashboardV1.init(extraOptions);
      default:
        return DashboardV2.init(extraOptions);
    }
  }
}

export default _window.SPFrontPanel.init;


