import { configureStore } from '@reduxjs/toolkit';
import styleReducer from './styleSlice';
import mainReducer from './mainSlice';
import authSlice from './authSlice';
import openAiSlice from './openAiSlice';

import usersSlice from "./users/usersSlice";
import rolesSlice from "./roles/rolesSlice";
import permissionsSlice from "./permissions/permissionsSlice";
import organizationsSlice from "./organizations/organizationsSlice";
import workspacesSlice from "./workspaces/workspacesSlice";
import workspace_membershipsSlice from "./workspace_memberships/workspace_membershipsSlice";
import ai_modelsSlice from "./ai_models/ai_modelsSlice";
import ai_agentsSlice from "./ai_agents/ai_agentsSlice";
import agent_skillsSlice from "./agent_skills/agent_skillsSlice";
import agent_skill_assignmentsSlice from "./agent_skill_assignments/agent_skill_assignmentsSlice";
import conversationsSlice from "./conversations/conversationsSlice";
import messagesSlice from "./messages/messagesSlice";
import message_attachmentsSlice from "./message_attachments/message_attachmentsSlice";
import code_snippetsSlice from "./code_snippets/code_snippetsSlice";
import executionsSlice from "./executions/executionsSlice";
import debug_sessionsSlice from "./debug_sessions/debug_sessionsSlice";
import debug_fixesSlice from "./debug_fixes/debug_fixesSlice";
import projectsSlice from "./projects/projectsSlice";
import project_filesSlice from "./project_files/project_filesSlice";
import previewsSlice from "./previews/previewsSlice";
import tool_integrationsSlice from "./tool_integrations/tool_integrationsSlice";
import api_keysSlice from "./api_keys/api_keysSlice";
import usage_eventsSlice from "./usage_events/usage_eventsSlice";
import audit_logsSlice from "./audit_logs/audit_logsSlice";

export const store = configureStore({
  reducer: {
    style: styleReducer,
    main: mainReducer,
    auth: authSlice,
    openAi: openAiSlice,

users: usersSlice,
roles: rolesSlice,
permissions: permissionsSlice,
organizations: organizationsSlice,
workspaces: workspacesSlice,
workspace_memberships: workspace_membershipsSlice,
ai_models: ai_modelsSlice,
ai_agents: ai_agentsSlice,
agent_skills: agent_skillsSlice,
agent_skill_assignments: agent_skill_assignmentsSlice,
conversations: conversationsSlice,
messages: messagesSlice,
message_attachments: message_attachmentsSlice,
code_snippets: code_snippetsSlice,
executions: executionsSlice,
debug_sessions: debug_sessionsSlice,
debug_fixes: debug_fixesSlice,
projects: projectsSlice,
project_files: project_filesSlice,
previews: previewsSlice,
tool_integrations: tool_integrationsSlice,
api_keys: api_keysSlice,
usage_events: usage_eventsSlice,
audit_logs: audit_logsSlice,
  },
})

// Infer the `RootState` and `AppDispatch` types from the store itself
export type RootState = ReturnType<typeof store.getState>
// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
export type AppDispatch = typeof store.dispatch
