import { shopeeSetting, appSetting, clearAllSetting } from '@/plugins/setting';

export const mutations = {
  /** @param {StoreSetting} state */
  SET_BETA_MODE(state) {
    state.isBetaMode = !state.isBetaMode;
    appSetting.betaMode.set(state.isBetaMode);
  },

  /** @param {StoreSetting} state */
  SET_WORKER_FETCH(state) {
    state.workerFetchService = !state.workerFetchService;
    appSetting.workerFetchService.set(state.workerFetchService);
  },

  /** @param {StoreSetting} state */
  SET_USE_SHOP_MANAGER(state) {
    state.useShopManager = !state.useShopManager;
    appSetting.useShopManager.set(state.useShopManager);
  },

  /**
   * @param {StoreSetting} state @param {string} tab
   * @param tab
   */
  SET_TAB(state, tab) {
    state.activeTab = tab;
    appSetting.activeTab.set(tab);
  },

  /**
   * @param {StoreSetting} state @param {object} config
   * @param config
   */
  SET_CLONE_SHOPEE(state, config) {
    state.shopeeConfigClone = config;
    shopeeSetting.shopeeConfigClone.set(config);
  },

  /**
   * @param {StoreSetting} state @param {object} value
   * @param value
   */
  SET_CONFIG_SHOPEE(state, value) {
    state.configShopee = value;
    shopeeSetting.shopeeConfigProduct.set(value);
  },

  /**
   * @param {StoreSetting} state @param {string[]} list
   * @param list
   */
  SET_BADWORD(state, list) {
    state.listBadWord = list;
    appSetting.badWord.set(list);
  },

  /**
   * @param {StoreSetting} state @param {string} base64
   * @param {object} payload
   */
  SET_WARTERMARK_PRODUCT_BASE64(state, payload) {
    const { base64, size } = payload;
    state.wartermarkProduct.base64 = base64;
    state.wartermarkProduct.size = size;
  },

  /**
   * @param {StoreSetting} state @param {boolean} active
   * @param active
   */
  SET_WARTERMARK_PRODUCT_ACTIVE(state, active) {
    state.wartermarkProduct.active = active;
  },

  SET_CLEAR() {
    clearAllSetting();
  },
};
