import { Command } from './command';
import { getCommonPath } from '../utils';
export class DeleteByPathsCmd extends Command {
    execute(options) {
        const { paths } = options;
        const commonPath = getCommonPath(paths);
        let undoPath = commonPath;
        let undoValue = this.store.get(commonPath);
        if (commonPath.length > 0) {
            const parentPath = commonPath.slice(0, -1);
            const parent = this.store.get(parentPath);
            if (Array.isArray(parent)) {
                undoPath = parentPath;
                undoValue = parent;
            }
        }
        this.store.deleteByPaths(paths);
        return () => {
            this.store.set(undoPath, undoValue);
        };
    }
}
