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

export class HcaptchaProvider extends SiteverifyCaptchaProvider {
  constructor(options: SiteverifyProviderOptions) {
    super(
      {
        name: "hcaptcha",
        endpoint: "https://api.hcaptcha.com/siteverify",
        client: {
          responseField: "h-captcha-response",
          scriptUrl: "https://js.hcaptcha.com/1/api.js?render=explicit",
          widgetClass: "h-captcha",
        },
        sendSiteKey: true,
        scoreDirection: "higher-is-risk",
      },
      options,
    );
  }
}

export function hcaptchaProvider(options: SiteverifyProviderOptions): HcaptchaProvider {
  return new HcaptchaProvider(options);
}
