<div class="d-flex justify-content-center">
  <div class="col-8">
    @if (inputData()) {
      <div>
        <h2 data-cy="inputDataDetailsHeading"><span jhiTranslate="resilientApp.inputData.detail.title">Input Data</span></h2>

        <hr />

        <jhi-alert-error></jhi-alert-error>

        <jhi-alert></jhi-alert>

        <dl class="row-md jh-entity-details">
          <dt><span jhiTranslate="global.field.id">Código</span></dt>
          <dd>
            <span>{{ inputData()!.id }}</span>
          </dd>
          
          <dt><span jhiTranslate="resilientApp.inputData.period">Period</span></dt>
          <dd>
            @if (inputData()!.period) {
              <div>
                <a [routerLink]="['/period', inputData()!.period?.id, 'view']">{{ inputData()!.period?.name }}</a>
              </div>
            }
          </dd>
          <dt><span jhiTranslate="resilientApp.inputData.owner">Owner</span></dt>
          <dd>
            @if (inputData()!.owner) {
              <div>
                <a [routerLink]="['/organization', inputData()!.owner?.id, 'view']">{{ inputData()!.owner?.name }}</a>
              </div>
            }
          </dd>
          
          <dt><span jhiTranslate="resilientApp.inputData.variable">Variable</span></dt>
          <dd>
            @if (inputData()!.variable) {
              <div>
                <a [routerLink]="['/variable', inputData()!.variable?.id, 'view']">{{ inputData()!.variable?.name }}</a>
              </div>
            }
          </dd>
          
          <dt><span jhiTranslate="resilientApp.inputData.variableClass">Variable Class</span></dt>
          <dd>
            @if (inputData()!.variableClassName) {
              <div>
                {{ inputData()!.variableClassName }}
              </div>
            }
          </dd>
          <dt>
            <span [ngbTooltip]="'resilientApp.inputData.help.sourceValue' | translate" jhiTranslate="resilientApp.inputData.sourceValue"
              >Source Value</span
            >
          </dt>
          <dd>
            <span>{{ inputData()!.sourceValue }}</span>
          </dd>
          <dt><span jhiTranslate="resilientApp.inputData.sourceUnit">Source Unit</span></dt>
          <dd>
            @if (inputData()!.sourceUnit) {
              <div>
                <a [routerLink]="['/unit', inputData()!.sourceUnit?.id, 'view']">{{ inputData()!.sourceUnit?.name }}</a>
              </div>
            }
          </dd>
          
          <dt>
            <span [ngbTooltip]="'resilientApp.inputData.help.variableValue' | translate" jhiTranslate="resilientApp.inputData.variableValue"
              >Variable Value</span
            >
          </dt>
          <dd>
            <span>{{ inputData()!.variableValue }}</span>
          </dd>
          <dt><span jhiTranslate="resilientApp.inputData.unit">Unit</span></dt>
          <dd>
            @if (inputData()!.unit) {
              <div>
                <a [routerLink]="['/unit', inputData()!.unit?.id, 'view']">{{ inputData()!.unit?.name }}</a>
              </div>
            }
          </dd>
          
          <dt>
            <span [ngbTooltip]="'resilientApp.inputData.help.imputedValue' | translate" jhiTranslate="resilientApp.inputData.imputedValue"
              >Imputed Value</span
            >
          </dt>
          <dd>
            <span>{{ inputData()!.imputedValue }}</span>
          </dd>
          <dt>
            <span [ngbTooltip]="'resilientApp.inputData.help.sourceType' | translate" jhiTranslate="resilientApp.inputData.sourceType"
              >Source Type</span
            >
          </dt>
          <dd>
            <span [jhiTranslate]="'resilientApp.DataSourceType.' + (inputData()!.sourceType ?? 'null')">{{
              { null: '', MANUAL: 'MANUAL', FILE: 'FILE', AUTO: 'AUTO', DISTRIB: 'DISTRIB' }[inputData()!.sourceType ?? 'null']
            }}</span>
          </dd>
          <dt>
            <span [ngbTooltip]="'resilientApp.inputData.help.dataDate' | translate" jhiTranslate="resilientApp.inputData.dataDate"
              >Data Date</span
            >
          </dt>
          <dd>
            <span>{{ inputData()!.dataDate | formatMediumDate }}</span>
          </dd>
          <dt>
            <span [ngbTooltip]="'resilientApp.inputData.help.changeDate' | translate" jhiTranslate="resilientApp.inputData.changeDate"
              >Change Date</span
            >
          </dt>
          <dd>
            <span>{{ inputData()!.changeDate | formatMediumDatetime }}</span>
          </dd>
          <dt>
            <span
              [ngbTooltip]="'resilientApp.inputData.help.changeUsername' | translate"
              jhiTranslate="resilientApp.inputData.changeUsername"
              >Change Username</span
            >
          </dt>
          <dd>
            <span>{{ inputData()!.changeUsername }}</span>
          </dd>
          <dt>
            <span [ngbTooltip]="'resilientApp.inputData.help.dataSource' | translate" jhiTranslate="resilientApp.inputData.dataSource"
              >Data Source</span
            >
          </dt>
          <dd>
            <span>{{ inputData()!.dataSource }}</span>
          </dd>
          <dt>
            <span [ngbTooltip]="'resilientApp.inputData.help.dataUser' | translate" jhiTranslate="resilientApp.inputData.dataUser"
              >Data User</span
            >
          </dt>
          <dd>
            <span>{{ inputData()!.dataUser }}</span>
          </dd>
          <dt>
            <span [ngbTooltip]="'resilientApp.inputData.help.dataComments' | translate" jhiTranslate="resilientApp.inputData.dataComments"
              >Data Comments</span
            >
          </dt>
          <dd>
            <span>{{ inputData()!.dataComments }}</span>
          </dd>
          <dt>
            <span [ngbTooltip]="'resilientApp.inputData.help.creationDate' | translate" jhiTranslate="resilientApp.inputData.creationDate"
              >Creation Date</span
            >
          </dt>
          <dd>
            <span>{{ inputData()!.creationDate | formatMediumDatetime }}</span>
          </dd>
          <dt>
            <span
              [ngbTooltip]="'resilientApp.inputData.help.creationUsername' | translate"
              jhiTranslate="resilientApp.inputData.creationUsername"
              >Creation Username</span
            >
          </dt>
          <dd>
            <span>{{ inputData()!.creationUsername }}</span>
          </dd>
          <dt>
            <span [ngbTooltip]="'resilientApp.inputData.help.version' | translate" jhiTranslate="resilientApp.inputData.version"
              >Version</span
            >
          </dt>
          <dd>
            <span>{{ inputData()!.version }}</span>
          </dd>


          <dt><span jhiTranslate="resilientApp.inputData.sourceInputData">Source Input Data</span></dt>
          <dd>
            @if (inputData()!.sourceInputData) {
              <div>
                <a [routerLink]="['/input-data', inputData()!.sourceInputData?.id, 'view']">{{ inputData()!.sourceInputData?.id }}</a>
              </div>
            }
          </dd>
          <dt><span jhiTranslate="resilientApp.inputData.sourceInputDataUpload">Source Input Data Upload</span></dt>
          <dd>
            @if (inputData()!.sourceInputDataUpload) {
              <div>
                <a [routerLink]="['/input-data-upload', inputData()!.sourceInputDataUpload?.id, 'view']">{{
                  inputData()!.sourceInputDataUpload?.id
                }}</a>
              </div>
            }
          </dd>
        </dl>

        <button type="submit" (click)="previousState()" class="btn btn-info" data-cy="entityDetailsBackButton">
          <fa-icon icon="arrow-left"></fa-icon>&nbsp;<span jhiTranslate="entity.action.back">Voltar</span>
        </button>

        <button 
          type="button" 
          class="btn btn-primary"

          *ngIf="hasUpdatePermission(Resources.INPUT_DATA)"
          [routerLink]="!canUpdate(inputData()) ? null : ['/input-data', inputData()!.id, 'edit']" 
          [class.disabled]="!canUpdate(inputData())"
          [disabled]="!canUpdate(inputData()) ? true : null"
        >
          <fa-icon icon="pencil-alt"></fa-icon>&nbsp;<span jhiTranslate="entity.action.edit">Editar</span>
        </button>
      </div>
    }
  </div>
</div>
