import { SteamUser } from '@/types/steam'
import { create } from 'zustand'

const mock_user: SteamUser = {
  steamID64: "76561198052315353",
  steamID32: "STEAM_0:0:46157676",
  accountName: "wrr",
  personaName: "wrr",
  recent: 0,
  avatar: "",
  // "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/0d/0d1d4b9e1a9e8b2b3d4d0a7e1b3d6b1e3f8f4f7.jpg",
}

interface SteamState {
  dir: string,
  csDir: string,
  users: SteamUser[],
  currentUser: () => SteamUser,
  isDirValid: boolean,
  isCsDirValid: boolean,
  init: () => void,
  updateDir: (dir: string) => void,
  updateCsDir: (dir: string) => void,
}

const useSteamStore = create<SteamState>()((set, get) => ({
  // 路径
  dir: "C:\\Program Files (x86)\\Steam",
  csDir: "",
  users: [mock_user] as SteamUser[],
  currentUser: () => {
    return get().users[0] || mock_user
  },
  // 路径是否可用
  isDirValid: false,
  isCsDirValid: false,
  init: () => {
    console.log('init')
  },
  updateDir: (dir: string) => set(() => ({ dir: dir })),
  updateCsDir: (dir: string) => set(() => ({ csDir: dir })),
  // increasePopulation: () => set((state) => ({ bears: state.bears + 1 })),
}))

export default useSteamStore