import { BaseCommand } from './base-command'; import type { Selection } from '@/types/selection'; import { useSelectionStore } from '@/store/selection-store'; export class CreateSelectionCommand extends BaseCommand { private previousSelection: Selection | null; private newSelection: Selection; constructor(newSelection: Selection) { super('Create Selection'); this.previousSelection = useSelectionStore.getState().activeSelection; this.newSelection = newSelection; } execute(): void { useSelectionStore.getState().setActiveSelection(this.newSelection); } undo(): void { useSelectionStore.getState().setActiveSelection(this.previousSelection); } } export class ClearSelectionCommand extends BaseCommand { private previousSelection: Selection | null; constructor() { super('Clear Selection'); this.previousSelection = useSelectionStore.getState().activeSelection; } execute(): void { useSelectionStore.getState().clearSelection(); } undo(): void { useSelectionStore.getState().setActiveSelection(this.previousSelection); } } export class InvertSelectionCommand extends BaseCommand { constructor() { super('Invert Selection'); } execute(): void { useSelectionStore.getState().invertSelection(); } undo(): void { // Invert is its own inverse useSelectionStore.getState().invertSelection(); } }