import StrategyCallbacks from '../../../../enums/StrategyCallbacks';
export default {
    [StrategyCallbacks.INTERNAL_setValue]: (operationData, { value, index }) => {
        const { segmentsLocked, segmentIndex, previewSegmentIndex, segmentationVoxelManager, memo, } = operationData;
        const previewVoxelManager = memo?.voxelManager || operationData.previewVoxelManager;
        const existingValue = segmentationVoxelManager.getAtIndex(index);
        let changed = false;
        if (segmentIndex === null) {
            const oldValue = previewVoxelManager.getAtIndex(index);
            if (oldValue !== undefined) {
                changed = previewVoxelManager.setAtIndex(index, oldValue);
            }
            return;
        }
        if (existingValue === segmentIndex || segmentsLocked.includes(value)) {
            return;
        }
        if (existingValue === previewSegmentIndex) {
            if (previewVoxelManager.getAtIndex(index) === undefined) {
                changed = segmentationVoxelManager.setAtIndex(index, segmentIndex);
            }
            else {
                return;
            }
        }
        const useSegmentIndex = previewSegmentIndex ?? segmentIndex;
        changed = previewVoxelManager.setAtIndex(index, useSegmentIndex);
    },
};
