import { configureStore } from "@reduxjs/toolkit"
import textMessageReducer from "./features/textMessagesSlice"
import lobbyChatMessagesReducer from "./features/lobbyChatMessagesSlice"
import peopleReducer from "./features/peopleSlice"
import MusicianReducer from "./features/musiciansSlice"
import onlineMusicianReducer from "./features/onlineMusiciansSlice"
import sessionReducer from "./features/sessionsSlice"
import notificationReducer from './features/notificationSlice'
import latencyReducer from "./features/latencySlice"
import friendReducer from "./features/friendsSlice"
import sessionsHistoryReducer from "./features/sessionsHistorySlice"
import myJamTracksSlice from "./features/myJamTracksSlice"
import jamTrackSlice from "./features/jamTrackSlice"
import activeSessionReducer from "./features/activeSessionSlice"
import sessionUIReducer from "./features/sessionUISlice"
import mixersReducer from "./features/mixersSlice"
import mediaReducer from "./features/mediaSlice"
import sessionChatReducer from "./features/sessionChatSlice"

const store = configureStore({
  reducer: {
    textMessage: textMessageReducer,
    people: peopleReducer,
    musician: MusicianReducer,
    notification: notificationReducer,
    session: sessionReducer, // this is the slice that holds the session lists
    activeSession: activeSessionReducer, // this is the slice that holds the currently active session
    sessionUI: sessionUIReducer, // this is the slice that holds the session UI state (modals, panels)
    sessionChat: sessionChatReducer, // Phase 7: session chat state (messages, channels, unread tracking)
    mixers: mixersReducer, // Phase 5: mixer state (chat, broadcast, track mixers, metronome, media summary)
    media: mediaReducer, // Phase 5: media data (backing tracks, jam tracks, recorded tracks)
    latency: latencyReducer,
    onlineMusician: onlineMusicianReducer,
    lobbyChat: lobbyChatMessagesReducer,
    friend: friendReducer,
    sessionsHistory: sessionsHistoryReducer, // this is the slice that holds the sessions history
    myJamTrack: myJamTracksSlice,
    jamTrack: jamTrackSlice
  }
})

// Expose store for testing (development and test environments only)
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
  window.__REDUX_STORE__ = store;
}

export default store