<!--

    Copyright © 2016-2022 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<section [formGroup]="timeUnitSelectFormGroup" fxLayout="row" fxLayout.xs="column" fxLayoutGap.gt-xs="8px">
  <mat-form-field class="mat-block" fxFlex>
    <mat-label>{{ labelText | translate }}</mat-label>
    <input matInput type="number" min="0" formControlName="time" required>
    <mat-error *ngIf="timeUnitSelectFormGroup.get('time').hasError('required')">
      {{ requiredText | translate }}
    </mat-error>
    <mat-error *ngIf="timeUnitSelectFormGroup.get('time').hasError('pattern')">
      {{ patternText | translate }}
    </mat-error>
    <mat-error *ngIf="timeUnitSelectFormGroup.get('time').hasError('min')">
      {{ (minText || patternText) | translate : {min: minTime/1000} }}
    </mat-error>
  </mat-form-field>
  <mat-form-field class="mat-block" fxFlex>
    <mat-label translate>device-profile.condition-duration-time-unit</mat-label>
    <mat-select formControlName="unit">
      <mat-option *ngFor="let timeUnit of timeUnits" [value]="timeUnit">
        {{ timeUnitTranslations.get(timeUnit) | translate }}
      </mat-option>
    </mat-select>
  </mat-form-field>
</section>
