"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../../node_modules/.pnpm/vue3-lazyload@0.2.5-beta_a6dezdz3je235ci4e3tu4rayna/node_modules/vue3-lazyload/dist/vue3-lazyload.esm.js");
const utils = require("./utils.js");
require("../../node_modules/.pnpm/crypto-js@4.1.1/node_modules/crypto-js/index.js");
require("../enums/pageEnum.js");
require("../router/index.js");
require("../store/modules/designStore/designStore.js");
const pluginEnum = require("../enums/pluginEnum.js");
const designSetting = require("../settings/designSetting.js");
require("../../node_modules/.pnpm/vue@3.3.4/node_modules/vue/dist/vue.runtime.esm-bundler.js");
require("../components/GoLoading/index.js");
require("../components/GoSkeleton/index.vue.js");
const icon = require("../plugins/icon.js");
const { InformationCircleIcon } = icon.icon.ionicons5;
const loadingStart = () => {
  window["$loading"].start();
};
const loadingFinish = () => {
  setTimeout(() => {
    window["$loading"].finish();
  });
};
const loadingError = () => {
  setTimeout(() => {
    window["$loading"].error();
  });
};
const goDialog = (params) => {
  const {
    type,
    title,
    message,
    positiveText,
    negativeText,
    closeNegativeText,
    isMaskClosable,
    onPositiveCallback,
    onNegativeCallback,
    promise,
    promiseResCallback,
    promiseRejCallback
  } = params;
  const typeObj = {
    // 自定义
    [pluginEnum.DialogEnum.DELETE]: {
      fn: window["$dialog"].warning,
      message: message || "是否删除此数据?"
    },
    // 原有
    [pluginEnum.DialogEnum.WARNING]: {
      fn: window["$dialog"].warning,
      message: message || "是否执行此操作?"
    },
    [pluginEnum.DialogEnum.ERROR]: {
      fn: window["$dialog"].error,
      message: message || "是否执行此操作?"
    },
    [pluginEnum.DialogEnum.SUCCESS]: {
      fn: window["$dialog"].success,
      message: message || "是否执行此操作?"
    }
  };
  const dialog = typeObj[type || pluginEnum.DialogEnum.WARNING]["fn"]({
    // 导入其余 NaiveUI 支持参数
    ...params,
    title: title || "提示",
    icon: utils.renderIcon(InformationCircleIcon, { size: designSetting.dialogIconSize }),
    content: typeObj[type || pluginEnum.DialogEnum.WARNING]["message"],
    positiveText: positiveText || "确定",
    negativeText: closeNegativeText ? void 0 : negativeText || "取消",
    // 是否通过遮罩关闭
    maskClosable: isMaskClosable || designSetting.maskClosable,
    onPositiveClick: async () => {
      if (promise && onPositiveCallback) {
        dialog.loading = true;
        try {
          const res = await onPositiveCallback();
          promiseResCallback && promiseResCallback(res);
        } catch (err) {
          promiseRejCallback && promiseRejCallback(err);
        }
        dialog.loading = false;
        return;
      }
      onPositiveCallback && onPositiveCallback(dialog);
    },
    onNegativeClick: async () => {
      onNegativeCallback && onNegativeCallback(dialog);
    }
  });
};
exports.goDialog = goDialog;
exports.loadingError = loadingError;
exports.loadingFinish = loadingFinish;
exports.loadingStart = loadingStart;
