"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.actionLoggerMiddleware = exports.actionLogger = void 0;
class ActionLogger {
  logs = [];
  maxLogs = 100;
  logAction(action, state) {
    if (process.env.NODE_ENV !== 'development') {
      return;
    }
    const entry = {
      timestamp: Date.now(),
      action,
      state,
      stackTrace: new Error().stack || ''
    };
    this.logs.push(entry);
    if (this.logs.length > this.maxLogs) {
      this.logs = this.logs.slice(-this.maxLogs);
    }
    if (typeof action !== 'object' || action === null) {
      console.error('🚨 Non-plain object action detected:', action);
      console.error('📋 Action type:', typeof action);
      console.error('🔍 Constructor:', action?.constructor?.name);
      console.error('📍 Stack trace:', entry.stackTrace);
    }
    if (!action.type) {
      console.error('🚨 Action missing type property:', action);
      console.error('📍 Stack trace:', entry.stackTrace);
    }
  }
  getLogs() {
    return [...this.logs];
  }
  clearLogs() {
    this.logs = [];
  }
  getRecentLogs(count = 10) {
    return this.logs.slice(-count);
  }
}
const actionLogger = exports.actionLogger = new ActionLogger();
const actionLoggerMiddleware = storeAPI => next => action => {
  if (process.env.NODE_ENV === 'development') {
    actionLogger.logAction(action, storeAPI.getState());
  }
  return next(action);
};
exports.actionLoggerMiddleware = actionLoggerMiddleware;
//# sourceMappingURL=actionLogger.js.map