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

<PageHeader as |p|>
  <p.top>
    <KeyValueHeader
      @baseKey={{this.key}}
      @path="vault.cluster.secrets.backend.list"
      @mode={{this.mode}}
      @root={{this.root}}
      @showCurrent={{true}}
    />
  </p.top>
  <p.levelLeft>
    <h1 class="title is-3">
      {{#if (eq this.mode "create")}}
        Create Encryption Key
      {{else if (eq this.mode "edit")}}
        Edit Encryption Key
      {{else}}
        Encryption Key
        <code>{{this.key.id}}</code>
      {{/if}}
    </h1>
  </p.levelLeft>
</PageHeader>
{{#if (eq this.mode "create")}}
  <TransitFormCreate
    @createOrUpdateKey={{action "createOrUpdateKey" this.mode}}
    @setValueOnKey={{action "setValueOnKey" "exportable"}}
    @autoRotateInvalid={{this.autoRotateInvalid}}
    @handleAutoRotateChange={{action "handleAutoRotateChange"}}
    @derivedChange={{action "derivedChange" value="target.checked"}}
    @convergentEncryptionChange={{action "convergentEncryptionChange" value="target.checked"}}
    @key={{this.key}}
    @requestInFlight={{this.requestInFlight}}
  />
{{else if (eq this.mode "edit")}}
  <TransitFormEdit
    @createOrUpdateKey={{action "createOrUpdateKey" this.mode}}
    @setValueOnKey={{action "setValueOnKey" "deletionAllowed"}}
    @autoRotateInvalid={{this.autoRotateInvalid}}
    @handleAutoRotateChange={{action "handleAutoRotateChange"}}
    @deleteKey={{action "deleteKey"}}
    @key={{this.key}}
    @requestInFlight={{this.requestInFlight}}
    @capabilities={{this.capabilities}}
  />
{{else if (eq this.mode "show")}}
  <TransitFormShow
    @refresh={{action "refresh"}}
    @tab={{this.tab}}
    @key={{this.key}}
    @capabilities={{this.capabilities}}
    @mode={{this.mode}}
    @model={{this.model}}
    @backend={{this.backend}}
  />
{{else}}
  <EmptyState @title="No Transit mode selected" />
{{/if}}