import Logger, { LoggerKey } from "./Logger";
import ClassName from "../container/ClassName";
import { Injectable } from "../container/Injectable";
import CommonUtils, { CommonUtilsKey } from "./utils/CommonUtils";
import LocalConfigWrapper, { LocalConfigWrapperKey } from "./LocalConfigWrapper";
import NNB from "./handler/NNB";
import ItemPriceWatcherHandler from "./handler/ItemPriceWatcherHandler";
import { createApp } from "vue";
import FloatMenu from "../../vue/FloatMenu.vue";
import PopupWrapper, { PopupWrapperKey } from "./utils/PopupWrapper";
import InfoUtils from "./utils/InfoUtils";
import TravelItem, { TravelItemKey } from "./action/TravelItem";
import QuickGymTrain, { QuickGymTrainKey } from "./action/QuickGymTrain";
import QuickFlyBtnHandler, { QuickFlyBtnHandlerKey } from "./handler/QuickFlyBtnHandler";
import ItemHelper, { ItemHelperKey } from "./utils/ItemHelper";
import MathUtils, { MathUtilsKey } from "./utils/MathUtils";

@ClassName("IconHelper")
@Injectable()
export default class IconHelper {
    private readonly _element: HTMLElement;

    constructor(
        private readonly logger: Logger,
        private readonly commonUtils: CommonUtils,
        private readonly localConfigWrapper: LocalConfigWrapper,
        private readonly nnb: NNB,
        private readonly itemPriceWatcherHandler: ItemPriceWatcherHandler,
        private readonly popupWrapper: PopupWrapper,
        private readonly infoUtils: InfoUtils,
        private readonly travelItem: TravelItem,
        private readonly quickGymTrain: QuickGymTrain,
        private readonly quickFlyBtnHandler: QuickFlyBtnHandler,
        private readonly itemHelper: ItemHelper,
        private readonly mathUtils: MathUtils,
    ) {
        this._element = document.createElement('div');
    }

    get element() {
        return this._element;
    }

    init() {
        this._element.id = 'WHMenu2023';
        document.body.append(this._element);
        let app = createApp(FloatMenu);
        app.config.errorHandler = (err) => this.logger.error('[VUE错误]', err);
        app.config.warnHandler = (err) => this.logger.warn('[VUE警告]', err);
        app.provide(LoggerKey, this.logger);
        app.provide(CommonUtilsKey, this.commonUtils);
        app.provide(MathUtilsKey, this.mathUtils);
        app.provide(TravelItemKey, this.travelItem);
        app.provide(PopupWrapperKey, this.popupWrapper);
        app.provide(LocalConfigWrapperKey, this.localConfigWrapper);
        app.provide(QuickGymTrainKey, this.quickGymTrain);
        app.provide(QuickFlyBtnHandlerKey, this.quickFlyBtnHandler);
        app.provide(ItemHelperKey, this.itemHelper);
        app.mount(this._element);
    }

}
