/**
 * Cloudflare R2 provider config.
 * Reads ZEN_STORAGE_* environment variables.
 */

export function getConfig() {
  const host            = process.env.ZEN_STORAGE_ENDPOINT;
  const region          = process.env.ZEN_STORAGE_REGION ?? 'auto';
  const accessKeyId     = process.env.ZEN_STORAGE_ACCESS_KEY;
  const secretAccessKey = process.env.ZEN_STORAGE_SECRET_KEY;
  const bucket          = process.env.ZEN_STORAGE_BUCKET;

  if (!host || !accessKeyId || !secretAccessKey) {
    throw new Error(
      'Storage credentials are not configured. Please set ZEN_STORAGE_ENDPOINT, ZEN_STORAGE_ACCESS_KEY, and ZEN_STORAGE_SECRET_KEY.'
    );
  }
  if (!bucket) {
    throw new Error('ZEN_STORAGE_BUCKET environment variable is not set.');
  }

  return { accessKeyId, secretAccessKey, bucket, host, region };
}
