declare namespace MagicNode {
  export interface BaseCaptchaOptions {
    size?: number;
    noise?: number;
    width?: number;
    height?: number;
  }

  export interface CaptchaOptions extends BaseCaptchaOptions {
    image?: ImageCaptchaOptions;
    formula?: FormulaCaptchaOptions;
    text?: TextCaptchaOptions;
    expirationTime?: number;
    idPrefix?: string;
  }

  export interface ImageCaptchaOptions extends BaseCaptchaOptions {
    type?: 'number' | 'letter' | 'mixed';
  }

  export interface FormulaCaptchaOptions extends BaseCaptchaOptions {}

  export interface TextCaptchaOptions {
    size?: number;
    type?: 'number' | 'letter' | 'mixed';
  }

  export interface CaptchaService {
    image(options?: ImageCaptchaOptions): Promise<{
      id: string;
      imageBase64: string;
    }>;

    formula(options?: FormulaCaptchaOptions): Promise<{
      id: string;
      imageBase64: string;
    }>;

    text(options?: TextCaptchaOptions): Promise<{
      id: string;
      text: string;
    }>;

    set(text: string): Promise<string>;

    check(id: string, value: string): Promise<boolean>;
  }
}

/**
 * 导入模块
 */
declare interface ImportModule {
  /**
   * @param moduleName 模块名称
   */
  (moduleName: 'captchaService'): Promise<MagicNode.CaptchaService>;
}
