{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
~}}

<form id="auth-form" {{on "submit" (action "signIn")}}>
  <div class="field">
    <label for="role" class="is-label">Role</label>
    <div class="control">
      <input
        value={{this.roleName}}
        placeholder="Default"
        autocomplete="off"
        spellcheck="false"
        name="role"
        id="role"
        class="input"
        type="text"
        {{on "input" (action "onRoleChange")}}
        data-test-role
      />
    </div>
    <AlertInline
      class="has-top-padding-s"
      @type="info"
      @message="Leave blank to sign in with the default role if one is configured"
    />
  </div>
  {{#unless this.isOIDC}}
    <div class="field">
      <label for="jwt-token" class="is-label">JWT Token</label>
      <div class="control">
        <Input
          @type="password"
          @value={{this.jwt}}
          id="jwt-token"
          name="jwt"
          class="input"
          autocomplete="off"
          spellcheck="false"
          data-test-jwt
        />
      </div>
    </div>
  {{/unless}}
  <div data-test-yield-content>
    {{yield}}
  </div>

  {{#if this.isOIDC}}
    <Hds::Button
      @text={{concat "Sign in with " (or this.role.providerName "OIDC Provider")}}
      @icon={{if @disabled "loading" this.role.providerIcon}}
      data-test-auth-submit
      type="submit"
      disabled={{@disabled}}
      id="auth-submit"
    />
  {{else}}
    <Hds::Button
      @text="Sign in"
      @icon={{if @disabled "loading"}}
      data-test-auth-submit
      type="submit"
      disabled={{@disabled}}
      id="auth-submit"
    />
  {{/if}}
</form>