// /redux/store.ts
import { configureStore } from "@reduxjs/toolkit";
import { useDispatch } from "react-redux";
import authReducer from "./slices/authSlice";
import kueChartModeReducer from "./slices/kueChartModeSlice";
import webVersionReducer from "./slices/webVersionSlice";
import kabelueberwachungChartReducer from "./slices/kabelueberwachungChartSlice";
import last20MessagesReducer from "./slices/last20MessagesSlice";
import systemSettingsReducer from "./slices/systemSettingsSlice";
import opcuaSettingsReducer from "./slices/opcuaSettingsSlice";
import digitalOutputsReducer from "./slices/digitalOutputsSlice";
import brushReducer from "./slices/brushSlice";
import tdrChartReducer from "./slices/tdrChartSlice";
import analogeEingaengeReducer from "./slices/analogeEingaengeSlice";
import digitalInputsReducer from "./slices/digitalInputsSlice";
import tdrReferenceChartReducer from "./slices/tdrReferenceChartSlice";
import loopChartReducer from "./slices/loopChartSlice";
import tdmChartReducer from "./slices/tdmChartSlice";
import tdrDataByIdReducer from "./slices/tdrDataByIdSlice";
import kueDataReducer from "./slices/kueDataSlice";
import selectedChartDataReducer from "./slices/selectedChartDataSlice";
import tdmSingleChartReducer from "./slices/tdmSingleChartSlice";
import tdrReferenceChartDataBySlotReducer from "./slices/tdrReferenceChartDataBySlotSlice";
import loopChartTypeSlice from "./slices/loopChartTypeSlice";
import systemVoltTempReducer from "./slices/systemVoltTempSlice";
import analogInputsHistoryReducer from "./slices/analogInputsHistorySlice";

const store = configureStore({
  reducer: {
    authSlice: authReducer,
    kueChartModeSlice: kueChartModeReducer,
    webVersionSlice: webVersionReducer,
    digitalInputsSlice: digitalInputsReducer,
    kabelueberwachungChartSlice: kabelueberwachungChartReducer,
    last20MessagesSlice: last20MessagesReducer,
    systemSettingsSlice: systemSettingsReducer,
    opcuaSettingsSlice: opcuaSettingsReducer,
    digitalOutputsSlice: digitalOutputsReducer,
    analogeEingaengeSlice: analogeEingaengeReducer,
    brushSlice: brushReducer,
    tdrChartSlice: tdrChartReducer,
    tdrReferenceChartSlice: tdrReferenceChartReducer,
    loopChartSlice: loopChartReducer,
    tdmChartSlice: tdmChartReducer,
    tdrDataByIdSlice: tdrDataByIdReducer,
    kueDataSlice: kueDataReducer,
    selectedChartDataSlice: selectedChartDataReducer,
    tdmSingleChartSlice: tdmSingleChartReducer,
    tdrReferenceChartDataBySlotSlice: tdrReferenceChartDataBySlotReducer,
    loopChartType: loopChartTypeSlice,
    systemVoltTemp: systemVoltTempReducer,
    analogInputsHistory: analogInputsHistoryReducer,
  },
});

export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;
export const useAppDispatch: () => AppDispatch = useDispatch; // ✅ Typisierte Dispatch-Funktion

export default store;
