import { d as defineEventHandler, c as createError, bo as getStorageProvider, s as setResponseHeader } 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 ____path__get = defineEventHandler(async (event) => {
  var _a, _b;
  try {
    const path = (_a = event.context.params) == null ? void 0 : _a.path;
    if (!path) {
      throw createError({
        statusCode: 400,
        statusMessage: "Bad Request",
        message: "File path is required"
      });
    }
    const storage = getStorageProvider();
    const exists = await storage.exists(path);
    if (!exists) {
      throw createError({
        statusCode: 404,
        statusMessage: "Not Found",
        message: "File not found"
      });
    }
    const fileBuffer = await storage.getFile(path);
    const ext = (_b = path.split(".").pop()) == null ? void 0 : _b.toLowerCase();
    const mimeTypes = {
      // Images
      "jpg": "image/jpeg",
      "jpeg": "image/jpeg",
      "png": "image/png",
      "gif": "image/gif",
      "webp": "image/webp",
      "svg": "image/svg+xml",
      "ico": "image/x-icon",
      // Documents
      "pdf": "application/pdf",
      "doc": "application/msword",
      "docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
      "xls": "application/vnd.ms-excel",
      "xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
      "ppt": "application/vnd.ms-powerpoint",
      "pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
      // Archives
      "zip": "application/zip",
      "rar": "application/x-rar-compressed",
      "7z": "application/x-7z-compressed",
      "tar": "application/x-tar",
      "gz": "application/gzip",
      // Text
      "txt": "text/plain",
      "html": "text/html",
      "css": "text/css",
      "js": "application/javascript",
      "json": "application/json",
      "xml": "application/xml",
      // Video
      "mp4": "video/mp4",
      "webm": "video/webm",
      "ogg": "video/ogg",
      "avi": "video/x-msvideo",
      "mov": "video/quicktime",
      // Audio
      "mp3": "audio/mpeg",
      "wav": "audio/wav",
      "flac": "audio/flac",
      "aac": "audio/aac",
      "oga": "audio/ogg"
    };
    const mimeType = ext ? mimeTypes[ext] || "application/octet-stream" : "application/octet-stream";
    setResponseHeader(event, "Content-Type", mimeType);
    setResponseHeader(event, "Content-Length", fileBuffer.length);
    setResponseHeader(event, "Cache-Control", "public, max-age=31536000");
    return fileBuffer;
  } catch (error) {
    const err = error;
    console.error("File serving error:", error);
    throw createError({
      statusCode: err.statusCode || 500,
      statusMessage: err.statusMessage || "Internal Server Error",
      message: err.message || "Failed to serve file"
    });
  }
});

export { ____path__get as default };
//# sourceMappingURL=_...path_.get.mjs.map
