import { fileURLToPath as __fileURLToPath } from 'url';
import { dirname as __pathDirname } from 'path';
const __filename = __fileURLToPath(import.meta.url);
const __dirname = __pathDirname(__filename);
function getEnv(key, defaultValue) {
  const value = process.env[key];
  if (!value && !defaultValue) {
    throw new Error(`Environment variable ${key} is required but not set`);
  }
  return value || defaultValue || "";
}
function getOptionalEnv(key, defaultValue) {
  return process.env[key] || defaultValue;
}
function getRequiredEnv(key) {
  const value = process.env[key];
  if (!value) {
    throw new Error(`Environment variable ${key} is required but not set`);
  }
  return value;
}
function getBooleanEnv(key, defaultValue = false) {
  const value = process.env[key];
  if (!value) return defaultValue;
  return value.toLowerCase() === "true" || value === "1";
}
function getNumberEnv(key, defaultValue) {
  const value = process.env[key];
  if (!value) {
    if (defaultValue === void 0) {
      throw new Error(`Environment variable ${key} is required but not set`);
    }
    return defaultValue;
  }
  const num = parseInt(value, 10);
  if (isNaN(num)) {
    throw new Error(
      `Environment variable ${key} must be a number, got: ${value}`
    );
  }
  return num;
}
export {
  getBooleanEnv,
  getEnv,
  getNumberEnv,
  getOptionalEnv,
  getRequiredEnv
};
//# sourceMappingURL=env.js.map
