import { f as defineAdminEventHandler, aA as requireSuperAdmin, c as createError, ag as findAdminUserById, a6 as getAdminMfaState } from '../../../../../nitro/nitro.mjs';
import 'node:crypto';
import 'jsonwebtoken';
import 'node:fs';
import 'node:module';
import 'node:path';
import 'node:url';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'pino';
import 'drizzle-orm/better-sqlite3';
import 'drizzle-orm/node-postgres';
import 'drizzle-orm/mysql2';
import 'better-sqlite3';
import 'pg';
import 'mysql2/promise';
import 'drizzle-orm';
import 'fs';
import 'path';
import 'prom-client';
import 'bcryptjs';
import '@node-rs/argon2';
import 'node:async_hooks';
import 'crypto';
import 'node:dns';
import 'node:util';
import 'node:net';
import 'fs/promises';
import 'url';
import 'semver';

const mfa_get = defineAdminEventHandler("admin:users:mfa:get", async (event) => {
  var _a, _b, _c, _d;
  await requireSuperAdmin(event);
  const userId = Number((_a = event.context.params) == null ? void 0 : _a.id);
  if (!Number.isInteger(userId) || userId <= 0) {
    throw createError({
      statusCode: 400,
      statusMessage: "Bad Request",
      message: "Invalid user id"
    });
  }
  const target = await findAdminUserById(userId, { includeInactive: true });
  if (!target) {
    throw createError({ statusCode: 404, statusMessage: "Not Found", message: "User not found" });
  }
  const state = await getAdminMfaState(userId);
  return {
    success: true,
    data: {
      userId,
      username: target.username,
      role: target.role,
      enabled: Boolean(state == null ? void 0 : state.enabled),
      enrolledAt: (_b = state == null ? void 0 : state.enrolledAt) != null ? _b : null,
      lastVerifiedAt: (_c = state == null ? void 0 : state.lastVerifiedAt) != null ? _c : null,
      recoveryCodesRemaining: (_d = state == null ? void 0 : state.recoveryHashes.length) != null ? _d : 0
    }
  };
});

export { mfa_get as default };
//# sourceMappingURL=mfa.get.mjs.map
