<!--

    Copyright © 2016-2026 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]="parentForm">
  <tb-country-autocomplete
    appearance="outline"
    formControlName="country"
    (selectCountryCode)="changeCountry($event)">
  </tb-country-autocomplete>
  <div class="tb-form-row column-xs tb-standard-fields no-border no-padding">
    <mat-form-field class="flex" appearance="outline" subscriptSizing="dynamic">
      <mat-label translate>contact.city</mat-label>
      <input matInput formControlName="city">
      @if (parentForm.get('city').hasError('maxlength')) {
        <mat-error>{{ 'contact.city-max-length' | translate }}</mat-error>
      }
      <mat-hint></mat-hint>
    </mat-form-field>
    <mat-form-field class="flex" appearance="outline" subscriptSizing="dynamic">
      <mat-label translate>contact.state</mat-label>
      <input matInput formControlName="state">
      @if (parentForm.get('state').hasError('maxlength')) {
        <mat-error>{{ 'contact.state-max-length' | translate }}</mat-error>
      }
      <mat-hint></mat-hint>
    </mat-form-field>
    <mat-form-field class="flex" appearance="outline" subscriptSizing="dynamic">
      <mat-label translate>contact.postal-code</mat-label>
      <input matInput formControlName="zip">
      @if (parentForm.get('zip').hasError('pattern')) {
        <mat-error>{{ 'contact.postal-code-invalid' | translate }}</mat-error>
      }
      <mat-hint></mat-hint>
    </mat-form-field>
  </div>
  <mat-form-field class="mat-block" appearance="outline">
    <mat-label translate>contact.address</mat-label>
    <input matInput formControlName="address">
  </mat-form-field>
  <mat-form-field class="mat-block" appearance="outline">
    <mat-label translate>contact.address2</mat-label>
    <input matInput formControlName="address2">
  </mat-form-field>
  <tb-phone-input [required]="false"
                  [defaultCountry]="phoneInputDefaultCountry"
                  label="{{ 'contact.phone' | translate }}"
                  appearance="outline"
                  [enableFlagsSelect]="true"
                  formControlName="phone">
  </tb-phone-input>
  <mat-form-field class="mat-block" appearance="outline">
    <mat-label translate>contact.email</mat-label>
    <input matInput type="email" formControlName="email">
    @if (parentForm.get('email').hasError('email')) {
      <mat-error>{{ 'user.invalid-email-format' | translate }}</mat-error>
    }
  </mat-form-field>
</section>
