import { y as defineEventHandler, ac as getValidatedQuery, a as APUser, I as Instance } from '../../nitro/nitro.mjs';
import { r as requireAdminSession } from '../../_/session.mjs';
import { z } from 'zod';
import 'luxon';
import '@sequelize/core';
import 'html-to-text';
import 'crypto';
import 'node:fs';
import 'sharp';
import 'path';
import 'node:stream';
import 'jsdom';
import 'dompurify';
import 'mime-types';
import 'fs';
import 'fs/promises';
import 'linkify-html';
import '@peertube/http-signature';
import 'jsonld';
import 'lodash.intersection';
import 'email-templates';
import 'node:http';
import 'node:https';
import 'node:crypto';
import 'node:events';
import 'node:buffer';
import 'node:path';
import 'vue';
import 'vue-router';
import 'dotenv';
import 'url';
import 'bcryptjs';
import 'slugify';
import 'umzug';
import 'consola';
import '@sequelize/core/decorators-legacy';
import 'util';
import 'mitt';
import 'ical.js';
import 'node:url';
import 'fast-xml-parser';
import '../../_/getUser.mjs';
import '../../_/jwt.mjs';
import 'jose';

const schema = z.object({
  instance: z.string().optional()
});
const index_get = defineEventHandler(async (event) => {
  await requireAdminSession(event);
  const query = await getValidatedQuery(event, schema.parse);
  const where = {};
  if (query.instance) {
    where.instanceDomain = query.instance;
  }
  const users = await APUser.findAll({ where, include: [{ model: Instance, required: true }] });
  return users.map((t) => ({
    ap_id: t.ap_id,
    following: t.following,
    trusted: t.trusted,
    blocked: t.blocked,
    follower: t.follower,
    url: t.object.url,
    icon: t.object?.icon?.url,
    name: t.object.name,
    preferredUsername: t.object.preferredUsername,
    summary: t.object.summary,
    domain: t.instance?.domain,
    software: {
      name: t.instance?.data?.software?.name ?? "",
      version: t.instance?.data?.software?.version ?? ""
    }
  }));
});

export { index_get as default };
