import { defineStore } from 'pinia';
import { useSessionStorage, tryOnMounted } from '@vueuse/core';
import '../../../../api/guardBasic/controller/index.mjs';
import { usePostBasicV1CountryList } from '../../../../api/guardBasic/controller/JiChuFuWu/QuYuGuanLi/usePostBasicV1CountryList.mjs';

const useCountryListStore = defineStore("gmCountryList", () => {
  const { isLoading, exec } = usePostBasicV1CountryList();
  const countryList = useSessionStorage("gmCountryList", [], { listenToStorageChanges: false });
  const getCountryList = async () => {
    if (countryList.value.length !== 0 || isLoading.value) {
      return;
    }
    return exec().then((response) => {
      if (response.data.value?.code == 200) {
        countryList.value = response.data.value?.data || [];
      }
    });
  };
  tryOnMounted(() => {
    getCountryList();
  });
  return {
    countryList,
    isLoading,
    getCountryList
  };
});

export { useCountryListStore };
//# sourceMappingURL=index.mjs.map
