import NavHeader from "./components/nav-header/NavHeader.vue";
import MyApps from "./components/my-apps/MyApps.vue";
import UserInfo from "./components/user-info/UserInfo.vue";
import LeftMenu from "./components/left-menu/LeftMenu.vue";
import BreadcrumbNav from "@/components/breadcrumb-nav/BreadcrumbNav.vue";
import Vue from "vue";
import { authService } from "@dhccmobile/etbc-auth-api";
import { CoreConfig } from "@/model/CoreConfig";
export * from "./components/index";
export * from "./constants/index";
export * from "./model/index";
export * from "./services/index";
export * from "./stores/index";
export * from "./types/ec";

const components: any = {
  NavHeader: NavHeader,
  MyApps: MyApps,
  UserInfo: UserInfo,
  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]);
  });

  vue.prototype.$ec = {
    sysId: options.sysId || "",
    baseApi: options.baseApi || ""
  };
  authService.authConfig = {
    apiBaseUrl: options.authApiBaseUrl || options.baseApi || ""
  };
};

const VueEc = {
  install
};
export default VueEc;
