import { App, createApp, h } from 'vue';

import { createPinia } from 'pinia';

import { setupGlobDirectives } from '../../directives';
import JnpfUniver from './Design/index.vue';
import JnpfUniverCellEchart from './Design/univer/components/Echart/cell.vue';
import JnpfUniverFloatEchartVM from './Design/univer/components/Echart/floatVM.vue';
import JnpfUniverPrint from './Print/Render/index.vue';

const pinia = createPinia();

const app = createApp(h('div'));

app.use(pinia);
setupGlobDirectives(app);

JnpfUniver.install = (app: App) => app.component(JnpfUniver.name as string, JnpfUniver);
JnpfUniverPrint.install = (app: App) => app.component(JnpfUniverPrint.name as string, JnpfUniverPrint);
JnpfUniverFloatEchartVM.install = (app: App) => app.component(JnpfUniverFloatEchartVM.name as string, JnpfUniverFloatEchartVM);
JnpfUniverCellEchart.install = (app: App) => app.component(JnpfUniverCellEchart.name as string, JnpfUniverCellEchart);

export { JnpfUniver, JnpfUniverCellEchart, JnpfUniverFloatEchartVM, JnpfUniverPrint };

export default {
  install(app: App) {
    app.component(JnpfUniver.name as string, JnpfUniver);
    app.component(JnpfUniverPrint.name as string, JnpfUniverPrint);
    app.component(JnpfUniverFloatEchartVM.name as string, JnpfUniverFloatEchartVM);
    app.component(JnpfUniverCellEchart.name as string, JnpfUniverCellEchart);
  },
};
