import type { SpreadsheetCommand } from '../types';

export function createPasteRangeCommand(
  persistBatch: (
    changes: Array<{ row: number; col: number; value: unknown }>,
  ) => void | Promise<void>,
  before: Array<{ row: number; col: number; value: unknown }>,
  after: Array<{ row: number; col: number; value: unknown }>,
): SpreadsheetCommand {
  return {
    label: 'pasteRange',
    undo: () => persistBatch(before),
    redo: () => persistBatch(after),
  };
}
