<form
  id="two-factor-page"
  #form
  (ngSubmit)="submit()"
  [appApiAction]="formPromise"
  attr.aria-hidden="{{ showingModal }}"
>
  <div id="content" class="content">
    <h1>{{ title }}</h1>
    <p *ngIf="selectedProviderType === providerType.Authenticator">
      {{ "enterVerificationCodeApp" | i18n }}
    </p>
    <p *ngIf="selectedProviderType === providerType.Email">
      {{ "enterVerificationCodeEmail" | i18n : twoFactorEmail }}
    </p>
    <div
      class="box last"
      *ngIf="
        selectedProviderType === providerType.Email ||
        selectedProviderType === providerType.Authenticator
      "
    >
      <div class="box-content">
        <div class="box-content-row" appBoxRow>
          <label for="code">{{ "verificationCode" | i18n }}</label>
          <input
            id="code"
            type="text"
            name="Code"
            [(ngModel)]="token"
            required
            appAutofocus
            appInputVerbatim
          />
        </div>
        <div class="box-content-row box-content-row-checkbox" appBoxRow>
          <label for="remember">{{ "rememberMe" | i18n }}</label>
          <input id="remember" type="checkbox" name="Remember" [(ngModel)]="remember" />
        </div>
      </div>
    </div>
    <ng-container *ngIf="selectedProviderType === providerType.Yubikey">
      <p>{{ "insertYubiKey" | i18n }}</p>
      <img src="../../images/yubikey.jpg" alt="" />
      <div class="box last">
        <div class="box-content">
          <div class="box-content-row" appBoxRow>
            <label for="code" class="sr-only">{{ "verificationCode" | i18n }}</label>
            <input
              id="code"
              type="password"
              name="Code"
              [(ngModel)]="token"
              required
              appAutofocus
              appInputVerbatim
            />
          </div>
          <div class="box-content-row box-content-row-checkbox" appBoxRow>
            <label for="remember">{{ "rememberMe" | i18n }}</label>
            <input id="remember" type="checkbox" name="Remember" [(ngModel)]="remember" />
          </div>
        </div>
      </div>
    </ng-container>
    <ng-container *ngIf="selectedProviderType === providerType.WebAuthn">
      <div id="web-authn-frame">
        <iframe id="webauthn_iframe"></iframe>
      </div>
      <div class="box first">
        <div class="box-content">
          <div class="box-content-row box-content-row-checkbox" appBoxRow>
            <label for="remember">{{ "rememberMe" | i18n }}</label>
            <input id="remember" type="checkbox" name="Remember" [(ngModel)]="remember" />
          </div>
        </div>
      </div>
    </ng-container>
    <ng-container
      *ngIf="
        selectedProviderType === providerType.Duo ||
        selectedProviderType === providerType.OrganizationDuo
      "
    >
      <div id="duo-frame"><iframe id="duo_iframe"></iframe></div>
      <div class="box last">
        <div class="box-content">
          <div class="box-content-row box-content-row-checkbox" appBoxRow>
            <label for="remember">{{ "rememberMe" | i18n }}</label>
            <input id="remember" type="checkbox" name="Remember" [(ngModel)]="remember" />
          </div>
        </div>
      </div>
    </ng-container>
    <div class="box last" *ngIf="selectedProviderType == null">
      <div class="box-content">
        <div class="box-content-row">
          <p>{{ "noTwoStepProviders" | i18n }}</p>
          <p>{{ "noTwoStepProviders2" | i18n }}</p>
        </div>
      </div>
    </div>
    <div class="box last" [hidden]="!showCaptcha()">
      <div class="box-content">
        <div class="box-content-row">
          <iframe id="hcaptcha_iframe" height="80"></iframe>
          <button class="btn block" type="button" routerLink="/accessibility-cookie">
            <i class="bwi bwi-universal-access" aria-hidden="true"></i>
            {{ "loadAccessibilityCookie" | i18n }}
          </button>
        </div>
      </div>
    </div>
    <div class="buttons">
      <button
        type="submit"
        class="btn primary block"
        [disabled]="form.loading"
        *ngIf="
          selectedProviderType != null &&
          selectedProviderType !== providerType.Duo &&
          selectedProviderType !== providerType.OrganizationDuo
        "
      >
        <span [hidden]="form.loading"
          ><i class="bwi bwi-sign-in" aria-hidden="true"></i> {{ "continue" | i18n }}</span
        >
        <i class="bwi bwi-spinner bwi-spin" [hidden]="!form.loading" aria-hidden="true"></i>
      </button>
      <button type="button" routerLink="/login" class="btn block">{{ "cancel" | i18n }}</button>
    </div>
    <div class="sub-options">
      <button type="button" appStopClick (click)="anotherMethod()">
        {{ "useAnotherTwoStepMethod" | i18n }}
      </button>
      <button
        type="button"
        appStopClick
        (click)="sendEmail(true)"
        [appApiAction]="emailPromise"
        *ngIf="selectedProviderType === providerType.Email"
      >
        {{ "sendVerificationCodeEmailAgain" | i18n }}
      </button>
    </div>
  </div>
</form>
<ng-template #twoFactorOptions></ng-template>
