import { f as defineAdminEventHandler, h as requireAdminRole, j as getQuery, x as listAIActions } 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 ADVISORS = [
  "schema",
  "migration",
  "editorial-qa",
  "scaffolding",
  "query",
  "automation"
];
const STATUSES = [
  "proposed",
  "approved",
  "rejected",
  "applied",
  "expired"
];
const TRUSTS = ["high", "medium", "low"];
const SEVERITIES = ["info", "warning", "critical"];
function parseList(raw, allowed) {
  if (typeof raw !== "string" || raw.length === 0) {
    return void 0;
  }
  const items = raw.split(",").map((s) => s.trim()).filter((s) => allowed.includes(s));
  return items.length > 0 ? items : void 0;
}
function parseInteger(raw) {
  if (typeof raw === "string" && raw.trim().length > 0) {
    const n = Number(raw);
    if (Number.isFinite(n) && n >= 0) {
      return Math.floor(n);
    }
  }
  return void 0;
}
const index_get = defineAdminEventHandler("admin:ai:actions:list", async (event) => {
  await requireAdminRole(event, ["super-admin", "admin"]);
  const query = getQuery(event);
  const filters = {};
  const advisor = parseList(query.advisor, ADVISORS);
  if (advisor) {
    filters.advisor = advisor;
  }
  const status = parseList(query.status, STATUSES);
  if (status) {
    filters.status = status;
  }
  const trust = parseList(query.trust, TRUSTS);
  if (trust) {
    filters.trust = trust;
  }
  const severity = parseList(query.severity, SEVERITIES);
  if (severity) {
    filters.severity = severity;
  }
  if (query.pendingOnly === "true" || query.pendingOnly === "1") {
    filters.pendingOnly = true;
  }
  if (typeof query.dateFrom === "string" && query.dateFrom.length > 0) {
    filters.dateFrom = query.dateFrom;
  }
  if (typeof query.dateTo === "string" && query.dateTo.length > 0) {
    filters.dateTo = query.dateTo;
  }
  const limit = parseInteger(query.limit);
  if (limit !== void 0) {
    filters.limit = limit;
  }
  const offset = parseInteger(query.offset);
  if (offset !== void 0) {
    filters.offset = offset;
  }
  const data = await listAIActions(filters);
  return { success: true, data };
});

export { index_get as default };
//# sourceMappingURL=index.get.mjs.map
