import { v4 as uuidv4 } from 'uuid';
import { addValues } from '../../../../../../../../commands';
export const getTransitionDuplicate = (transition) => {
    const duplicate = structuredClone(transition);
    duplicate.id = uuidv4();
    return duplicate;
};
export const copyByPaths = (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 = getTransitionDuplicate(value);
            acc.values.push(duplicate);
        }
        return acc;
    }, { values: [] });
    if (values.length) {
        dispatch(addValues(destinationPath, values));
    }
};
