import LeftMenu from "./components/left-menu/LeftMenu.vue";
import PageHeader from "./components/page-header/PageHeader.vue";
import BreadcrumbNav from "./components/breadcrumb-nav/BreadcrumbNav.vue";
import { CoreConfig } from "./model/CoreConfig";
import Vue from "vue";
import { routeTopologyService } from "./services/route-topology.service";
import { breadcrumbNavService } from "./services/breadcrumb-nav.service";
import "./styles/index.scss";
import Contextmenu from "vue-contextmenujs";
import { OauthConfig } from "./model/OauthConfig";
import { oauthService } from "./services/oauth.service";
import { userStore } from "./stores/user.store";
import { Modal } from "ant-design-vue";
export * from "./components/index";
export * from "./constants/index";
export * from "./model/index";
export * from "./services/index";
export * from "./stores/index";
export * from "./types/dc";

const components: any = {
  PageHeader: PageHeader,
  LeftMenu: LeftMenu,
  BreadcrumbNav: BreadcrumbNav,
};
const install: any = function (vue: typeof Vue, options: CoreConfig) {
  if (install.installed) return;
  install.installed = true;
  Object.keys(components).forEach((key) => {
    vue.component(key, components[key]);
  });

  const oauthConfig: OauthConfig = new OauthConfig(options.oauth);
  oauthConfig.scope = oauthConfig.scope ? oauthConfig.scope : "read";
  oauthConfig.state = oauthConfig.state ? oauthConfig.state : "oauth2";

  vue.use(Contextmenu as any);
  Vue.use(Modal);

  vue.prototype.$dc = {
    sysId: options.sysId || "",
    baseApi: options.baseApi || "",
    oauth: oauthConfig,
  };
  vue.prototype.$breadcrumbNavService = breadcrumbNavService;
  vue.prototype.$routeTopologyService = routeTopologyService;
  vue.prototype.$oauthService = oauthService;
  vue.prototype.$userStore = userStore;
};

const VueDc = {
  install,
};
export default VueDc;
