import {
    getTheme
} from "./packages/theme";
import directive from './packages/directive'
import error from './packages/utils/error'

import CompsMethods from './exposed'

/**
 * 引入elementui3.0
 *  "element-plus": "^2.2.0",
 */
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as Elicons from "@element-plus/icons-vue";

//引入echarts @5.3.3
import * as echarts from 'echarts'

//引入echarts-liquidfill @3.1.0
import 'echarts-liquidfill'

import lodash from 'lodash'

const {
    components,
    methods
} = CompsMethods;



const install = function (app, opts = {}) {

    app.use(ElementPlus)
    for (const name in Elicons) {
        app.component(name, Elicons[name]);
    }


    for (const key in components) {
        const comp = components[key]
        app.component(comp.name, comp);
    }

    app.config.globalProperties.$error = error;
    app.config.globalProperties.$theme = getTheme(opts.theme);
    app.config.globalProperties.$lodash = lodash;

    //样式类注册组件
    app.use(directive);

    app.provide('$echarts', echarts)
};

if (typeof window !== 'undefined' && window.Vue) {
    install(window.Vue);
}

export default {
    version: '1.3.4',
    install,
    ...components,
    ...methods
}
