import { SiteverifyCaptchaProvider, type SiteverifyProviderOptions } from "./siteverify.ts";

export class RecaptchaProvider extends SiteverifyCaptchaProvider {
  constructor(options: SiteverifyProviderOptions) {
    super(
      {
        name: "recaptcha",
        endpoint: "https://www.google.com/recaptcha/api/siteverify",
        client: {
          responseField: "g-recaptcha-response",
          scriptUrl: "https://www.google.com/recaptcha/api.js?render=explicit",
          widgetClass: "g-recaptcha",
        },
        scoreDirection: "higher-is-human",
      },
      options,
    );
  }
}

export function recaptchaProvider(options: SiteverifyProviderOptions): RecaptchaProvider {
  return new RecaptchaProvider(options);
}
