async function extractImageDimensions(buffer, mimeType) {
  if (!mimeType.startsWith("image/")) {
    return null;
  }
  try {
    const sharpModule = await import("sharp");
    const sharp = "default" in sharpModule ? sharpModule.default : sharpModule;
    const metadata = await sharp(buffer).metadata();
    if (metadata.width && metadata.height) {
      return {
        width: metadata.width,
        height: metadata.height
      };
    }
    return null;
  } catch {
    console.warn("[Media] Failed to extract image dimensions");
    return null;
  }
}
function getMediaTypeCategory(mimeType) {
  if (mimeType.startsWith("image/")) return "image";
  if (mimeType.startsWith("video/")) return "video";
  return "other";
}
function sanitizeFilename(filename) {
  return filename.replace(/[^a-zA-Z0-9._-]/g, "-").replace(/-+/g, "-").substring(0, 255);
}
export {
  extractImageDimensions,
  getMediaTypeCategory,
  sanitizeFilename
};
