import { z } from "zod";
import { restoreNotificationSchema } from "../../../data/validators.js";
import {
  NOTIFICATION_RESOURCE_KIND,
  notificationValidationErrorResponse,
  resolveNotificationContext,
  runGuardedNotificationWrite
} from "../../../lib/routeHelpers.js";
const metadata = {
  PUT: { requireAuth: true }
};
async function PUT(req, { params }) {
  const { id } = await params;
  const { service, scope, ctx } = await resolveNotificationContext(req);
  const body = await req.json().catch(() => ({}));
  const parsed = restoreNotificationSchema.safeParse(body);
  if (!parsed.success) {
    return notificationValidationErrorResponse(parsed.error);
  }
  const input = parsed.data;
  const guarded = await runGuardedNotificationWrite(
    ctx.container,
    scope,
    req,
    {
      resourceKind: NOTIFICATION_RESOURCE_KIND,
      resourceId: id,
      operation: "update",
      payload: input
    },
    () => service.restoreDismissed(id, input.status, scope)
  );
  if (!guarded.ok) return guarded.response;
  return Response.json({ ok: true });
}
const openApi = {
  PUT: {
    summary: "Restore dismissed notification",
    description: "Undo a dismissal and restore a notification to read or unread.",
    tags: ["Notifications"],
    parameters: [
      {
        name: "id",
        in: "path",
        required: true,
        schema: { type: "string", format: "uuid" }
      }
    ],
    requestBody: {
      required: false,
      content: {
        "application/json": {
          schema: restoreNotificationSchema
        }
      }
    },
    responses: {
      200: {
        description: "Notification restored",
        content: {
          "application/json": {
            schema: z.object({ ok: z.boolean() })
          }
        }
      }
    }
  }
};
export {
  PUT,
  metadata,
  openApi
};
//# sourceMappingURL=route.js.map
