import { StudioProjectState } from '../studio/types';

/**
 * Prepares a studio project state for edit mode by:
 * - Keeping only the first track
 * - Resetting track mix settings (amplitude, balance, mute, solo)
 *
 * This is typically called after fixStudioProjectState when loading a project in edit mode.
 */
export default function prepareStateForEditMode(
  state: StudioProjectState
): StudioProjectState {
  // Keep only the first track
  if (state.tracks.length > 1) {
    state.tracks = state.tracks.slice(0, 1);
  }

  // Reset mix settings on all tracks
  state.tracks.forEach((t) => {
    t.amplitude = 1.0;
    t.balance = 0;
    t.mute = false;
    t.solo = false;
  });

  return state;
}
