import { r as requireAdmin } from '../../../chunks/adminAuth_CY4OwU1a.mjs';
import { s as storeImageBuffer } from '../../../chunks/images_DSuHPXn1.mjs';
export { renderers } from '../../../renderers.mjs';

const POST = async (context) => {
  const unauthorized = requireAdmin(context);
  if (unauthorized) {
    return unauthorized;
  }
  const formData = await context.request.formData();
  const file = formData.get("image");
  if (!(file instanceof File) || file.size === 0) {
    return context.json({ error: "فایل تصویری ارسال نشده است." }, 400);
  }
  try {
    const storedImage = await storeImageBuffer(Buffer.from(await file.arrayBuffer()));
    return context.json(storedImage, 200);
  } catch {
    return context.json({ error: "پردازش تصویر ناموفق بود." }, 500);
  }
};

const _page = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
  __proto__: null,
  POST
}, Symbol.toStringTag, { value: 'Module' }));

const page = () => _page;

export { page };
