import { useSteamStore } from "@/store/steam"
import { useToolStore } from "@/store/tool"
import { TakeOff } from "@icon-park/react"
import { invoke } from "@tauri-apps/api/core"
import { Card, CardBody, CardHeader, CardIcon } from "../window/Card"
import { addToast, Button } from "@heroui/react"

const FastLaunch = () => {
  const steam = useSteamStore()
  const tool = useToolStore()

  return (
    <Card className="max-w-fit">
      <CardHeader>
        <CardIcon>
          <TakeOff /> 快捷启动
        </CardIcon>
      </CardHeader>
      <CardBody>
        <div className="flex gap-2">
          <Button
            size="md"
            onPress={() => {
              void invoke("launch_game", {
                steamPath: `${steam.state.steamDir}/steam.exe`,
                launchOption: tool.state.launchOptions[tool.state.launchIndex] || "",
                server: "perfectworld",
              })
              addToast({ title: "启动国服成功" })
            }}
            className="px-5 font-medium py-1.5 transition bg-red-200 dark:bg-red-900/60 rounded-full select-none"
          >
            启动国服
          </Button>
          <Button
            size="md"
            onPress={() => {
              void invoke("launch_game", {
                steamPath: `${steam.state.steamDir}/steam.exe`,
                launchOption: tool.state.launchOptions[tool.state.launchIndex] || "",
                server: "worldwide",
              })
              addToast({ title: "启动国际服成功" })
            }}
            className="px-5 font-medium py-1.5 transition bg-orange-200 dark:bg-orange-900/60 rounded-full select-none"
          >
            启动国际服
          </Button>
        </div>
      </CardBody>
    </Card>
  )
}

export default FastLaunch
