// Centralized, typed access to public environment variables
// NEXT_PUBLIC_* variables are exposed to the browser by Next.js at build time.

export const NODE_ENV = process.env.NODE_ENV;

const toNumber = (val: string | undefined): number | undefined => {
  if (val === undefined) return undefined;
  const n = Number(val);
  return Number.isFinite(n) ? n : undefined;
};

// RSL measurement duration in seconds. Default: 15s in dev, 120s otherwise.
export const RSL_DURATION_SECONDS: number = (() => {
  const fromEnv = toNumber(process.env.NEXT_PUBLIC_RSL_DURATION_SECONDS);
  if (fromEnv !== undefined) return fromEnv;
  return NODE_ENV === "development" ? 15 : 120;
})();
