"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useSecurityActivity = exports.useRecentSecurityActivity = void 0;
var _reactQuery = require("@tanstack/react-query");
var _queryKeys = require("./queryKeys");
var _OxyContext = require("../../context/OxyContext");
/**
 * Get user's security activity with pagination
 */
const useSecurityActivity = options => {
  const {
    oxyServices,
    activeSessionId
  } = (0, _OxyContext.useOxy)();
  return (0, _reactQuery.useQuery)({
    queryKey: _queryKeys.queryKeys.security.activity(options?.limit, options?.offset, options?.eventType),
    queryFn: async () => {
      if (!activeSessionId) {
        throw new Error('No active session');
      }
      const response = await oxyServices.getSecurityActivity(options?.limit, options?.offset, options?.eventType);
      return response;
    },
    enabled: options?.enabled !== false && !!activeSessionId,
    staleTime: 5 * 60 * 1000,
    // 5 minutes
    gcTime: 10 * 60 * 1000 // 10 minutes
  });
};

/**
 * Get recent security activity (convenience hook)
 */
exports.useSecurityActivity = useSecurityActivity;
const useRecentSecurityActivity = (limit = 10) => {
  const {
    oxyServices,
    activeSessionId
  } = (0, _OxyContext.useOxy)();
  return (0, _reactQuery.useQuery)({
    queryKey: _queryKeys.queryKeys.security.recent(limit),
    queryFn: async () => {
      if (!activeSessionId) {
        throw new Error('No active session');
      }
      return await oxyServices.getRecentSecurityActivity(limit);
    },
    enabled: !!activeSessionId,
    staleTime: 5 * 60 * 1000,
    // 5 minutes
    gcTime: 10 * 60 * 1000 // 10 minutes
  });
};
exports.useRecentSecurityActivity = useRecentSecurityActivity;
//# sourceMappingURL=useSecurityQueries.js.map