import { create } from "zustand"

interface KeyboardStore {
  ctrl: boolean
  setCtrl: (v: boolean) => void
  shift: boolean
  setShift: (v: boolean) => void
  drawAction: "none" | "add" | "subtract"
  setDrawAction: (mode: "none" | "add" | "subtract") => void
  copyDataIds: number[] // ctrl + c 复制数据
  setCopyDataIds: (ids: number[]) => void
}

export const useKeyboardStore = create<KeyboardStore>((set) => ({
  ctrl: false,
  shift: false,
  drawAction: "none",
  copyDataIds: [],
  setCtrl: (v) => set((state) => ({ ...state, ctrl: v })),
  setShift: (v) => set((state) => ({ ...state, shift: v })),
  setDrawAction: (mode) => set((state) => ({ ...state, drawAction: mode })),
  setCopyDataIds: (ids) => set((state) => ({ ...state, copyDataIds: ids })),
}))
