import { f as defineAdminEventHandler, h as requireAdminRole, i as requireApiTokenScopes, c as createError, bw as removeReleaseItem } 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 _itemId__delete = defineAdminEventHandler("admin:releases:remove-item", async (event) => {
  var _a, _b;
  try {
    await requireAdminRole(event, ["super-admin", "admin"]);
    requireApiTokenScopes(event.context.apiToken, { scopes: ["releases:write"] });
    const releaseId = Number((_a = event.context.params) == null ? void 0 : _a.id);
    const itemId = Number((_b = event.context.params) == null ? void 0 : _b.itemId);
    if (!releaseId || isNaN(releaseId) || !itemId || isNaN(itemId)) {
      throw createError({
        statusCode: 400,
        statusMessage: "Bad Request",
        message: "Valid release ID and item ID are required"
      });
    }
    await removeReleaseItem(releaseId, itemId);
    return {
      success: true,
      message: `Item ${itemId} removed from release ${releaseId}`
    };
  } catch (error) {
    if (error && typeof error === "object" && "statusCode" in error) {
      throw error;
    }
    if (error instanceof Error && error.message.includes("not found")) {
      throw createError({ statusCode: 404, statusMessage: "Not Found", message: error.message });
    }
    if (error instanceof Error && error.message.includes("Cannot remove")) {
      throw createError({ statusCode: 400, statusMessage: "Bad Request", message: error.message });
    }
    console.error("[DELETE /api/admin/content-releases/:id/items/:itemId] Error:", error);
    throw createError({
      statusCode: 500,
      statusMessage: "Failed to remove release item",
      message: error instanceof Error ? error.message : "Unknown error"
    });
  }
});

export { _itemId__delete as default };
//# sourceMappingURL=_itemId_.delete.mjs.map
