'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vConsole_vConsole = require('./v-console.js');
require('../dom/dom.js');
require('../loader/loader.js');
require('../loader/little-loader.js');
require('./config.js');
require('./plugin/delay.js');
require('./plugin/env.js');
require('./plugin/feedback.js');
require('../clipboard/clipboard-web.js');
require('./plugin/msdk.js');
require('./plugin/version.js');
require('@babel/runtime/helpers/toConsumableArray');
require('./plugin/version-simple.js');
require('../time/time.js');

var V_CONSOLE_STORAGE = {
  KEY: 'SHOW_V_CONSOLE',
  VALUE: '1'
};
/**
 * vConsole 当前展示状态
 * @example
 * ```ts
 * import { V_CONSOLE_STATE, toggleVConsole } from 't-comm';
 *
 * console.log(V_CONSOLE_STATE.show); // false
 * toggleVConsole();
 * console.log(V_CONSOLE_STATE.show); // true
 * ```
 */
var V_CONSOLE_STATE = {
  show: false
};
function loadTheVConsole() {
  vConsole_vConsole.loadVConsole().then(function (instance) {
    window.vConsole = instance;
  });
}
/**
 * 展示 vConsole
 * @example
 * ```ts
 * showVConsole()
 * ```
 */
function showVConsole() {
  V_CONSOLE_STATE.show = true;
  localStorage.setItem(V_CONSOLE_STORAGE.KEY, V_CONSOLE_STORAGE.VALUE);
  loadTheVConsole();
}
/**
 * 关闭 vConsole
 * @example
 * ```ts
 * closeVConsole()
 * ```
 */
function closeVConsole() {
  var _a;
  localStorage.removeItem(V_CONSOLE_STORAGE.KEY);
  V_CONSOLE_STATE.show = false;
  (_a = window.vConsole) === null || _a === void 0 ? void 0 : _a.destroy();
}
/**
 * 切换展示 vConsole
 * @returns 是否展示
 * @example
 * ```ts
 * toggleVConsole()
 * ```
 */
function toggleVConsole() {
  if (V_CONSOLE_STATE.show) {
    closeVConsole();
  } else {
    showVConsole();
  }
  return V_CONSOLE_STATE.show;
}
/**
 * 检查 localStorage 设置，并展示vConsole
 * @example
 * ```ts
 * checkAndShowVConsole()
 * ```
 */
function checkAndShowVConsole() {
  var showVConsole = localStorage.getItem(V_CONSOLE_STORAGE.KEY) === V_CONSOLE_STORAGE.VALUE;
  if (showVConsole) {
    V_CONSOLE_STATE.show = true;
    loadTheVConsole();
  }
}

exports.V_CONSOLE_STATE = V_CONSOLE_STATE;
exports.checkAndShowVConsole = checkAndShowVConsole;
exports.closeVConsole = closeVConsole;
exports.showVConsole = showVConsole;
exports.toggleVConsole = toggleVConsole;
