/**
 * Feature flags for controlling unreleased or in-progress features.
 *
 * Flip a flag to `true` when the feature is ready for release.
 * Once a flag has been `true` in a stable release for a while,
 * remove the flag and the gating code entirely.
 */

/**
 * Hard-coded default for the Next API OAuth feature gate.
 *
 * Set to `true` when the feature is ready for general release.
 */
const NEXT_API_AUTH_DEFAULT = false

/**
 * Whether the Next API OAuth authentication flow is available.
 *
 * Controlled by the compile-time default above **or** at runtime via
 * the `DIMCODE_ENABLE_NEXT_API_AUTH` environment variable (`"1"` to
 * force-enable, `"0"` to force-disable).
 */
export function isNextApiAuthEnabled(): boolean {
  const envOverride = (
    typeof process !== 'undefined'
      ? process.env?.DIMCODE_ENABLE_NEXT_API_AUTH
      : undefined
  )
  if (envOverride === '1')
    return true
  if (envOverride === '0')
    return false
  return NEXT_API_AUTH_DEFAULT
}
