const LOCAL_SIGNIN_ACTIONS = new Set(['password_login', 'email_code_start', 'google_login'])
const LOOPBACK_HOST = /^(?:localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/i

/** A local testing switch; production and non-loopback requests always verify. */
export function isLocalSigninCaptchaPaused(action: string, requestHost: string | null): boolean {
  return process.env.NODE_ENV === 'development'
    && process.env.NEXT_PUBLIC_DISABLE_RECAPTCHA_LOCAL_SIGNIN === 'true'
    && LOCAL_SIGNIN_ACTIONS.has(action)
    && LOOPBACK_HOST.test(requestHost ?? '')
}
