/**
 * These functions are used to neutralize the project state,
 * which means to remove all selections and focus from the project state.
 *
 * This functionality is replicated in the `frontend`
 * project as well under the same file name, even though the implementation is different.
 **/

const projectStateKeysToIgnore = [
  'metronome',
  'midiOverdub',
  'loopStart',
  'loopEnd',
  'loopLifted',
  'loopEnabled',
  'arrangementFocusCategory',
  'timelineSelectionStart',
  'timelineSelectionEnd',
  'arrangementFocusCategory',
  'headerAnchorTrackId',
  'timelineAnchorTrackId',
  'editorTypeIntent',
  'focusedTrackId',
  'focusedSignal',
  'selectedDeviceId',
  'countIn',
  'editorTypeIntent',
  'panelTree',
];

export const areProjectsEqual = (project1, project2) => {
  // Remove keys that are not relevant for project equality
  const project1Filtered = { ...project1 };
  const project2Filtered = { ...project2 };
  projectStateKeysToIgnore.forEach((key) => {
    delete project1Filtered[key];
    delete project2Filtered[key];
  });
  return JSON.stringify(project1Filtered) === JSON.stringify(project2Filtered);
};
