import { addValues, deleteByPaths } from '../../../../../../../../commands';
export const getFrameDuplicate = (frame) => {
    const duplicate = structuredClone(frame);
    return duplicate;
};
export const moveByPaths = (sourcePaths, destinationPath) => (dispatch, getState) => {
    const destination = getState(destinationPath);
    if (!Array.isArray(destination)) {
        return;
    }
    const { values } = sourcePaths.reduce((acc, path) => {
        const value = getState(path);
        if (value) {
            const duplicate = getFrameDuplicate(value);
            acc.values.push(duplicate);
        }
        return acc;
    }, { values: [] });
    if (values.length) {
        dispatch(addValues(destinationPath, values));
        dispatch(deleteByPaths(sourcePaths, true));
    }
};
