import { create } from 'zustand';

export interface CaptureItem {
  id: string;
  dataUrl: string;
  time: number;
  filename: string;
  createdAt: number;
}

interface CaptureStore {
  captures: CaptureItem[];
  addCapture: (item: CaptureItem) => void;
  removeCapture: (id: string) => void;
  clearCaptures: () => void;
}

export const useCaptureStore = create<CaptureStore>((set) => ({
  captures: [],
  addCapture: (item) => set((s) => ({ captures: [item, ...s.captures] })),
  removeCapture: (id) => set((s) => ({ captures: s.captures.filter((c) => c.id !== id) })),
  clearCaptures: () => set({ captures: [] }),
}));
