<form appFormSubmit (ngSubmit)="objectController.actionCallback(primaryAction)" [formGroup]="configurationDomainsForm">
  <!--suppress JSUnusedGlobalSymbols -->
  <app-form-errors #formErrors [formGroup]="configurationDomainsForm"></app-form-errors>

  <mat-accordion [multi]="true">
    <mat-expansion-panel>
      <mat-expansion-panel-header>
        <mat-panel-title class="full-width" i18n>Domain options</mat-panel-title>
      </mat-expansion-panel-header>
      <div layoutDirection="row" layoutDirection-xs="column" layoutDirection-sm="column">
        <div layoutDirection="column" appFlex="33" xsFlex="100" smFlex="100">
          <mat-checkbox formControlName="allow_domain_registration" color="primary" i18n>Allow domain registration</mat-checkbox>
          <mat-checkbox formControlName="allow_domain_transfer" color="primary" i18n>Allow domain transfer</mat-checkbox>
          <mat-checkbox formControlName="renew_domains_automatically_on_payment" color="primary"
                        i18n>Renew domains automatically on payment</mat-checkbox>
          <mat-checkbox formControlName="prevent_orders_with_existing_domains" color="primary"
                        i18n>Prevent order with existing domains</mat-checkbox>
        </div>
        <div layoutDirection="column" appFlex="66" xsFlex="100" smFlex="100">
          <div class="fl-help-text">
            <h3 i18n>Allow domain registration</h3>
            <p i18n>
              If this is checked new internet domain registration is allowed for the clients with this
              configuration.
            </p>
            <h3 i18n>Allow domain transfer</h3>
            <p i18n>If this is checked transfer of internet domains is allowed for the clients with this configuration.</p>
            <h3 i18n>Renew domains automatically on payment</h3>
            <p i18n>
              Renew domains automatically on successful payment if operation is supported by the registrar module,
              creates TODO entry otherwise.
            </p>
            <h3 i18n>Prevent order with existing domains</h3>
            <p i18n>
              When checked, end-users cannot place domain registration or domain transfer orders for domains that
              already exist in the database with a status other than Expired, Transferred away, Canceled, or Deleted.
              When checked, end-users cannot order services with an associated domain that is already associated with
              another service having a status other than Terminated or Canceled.
            </p>
          </div>
        </div>
      </div>
    </mat-expansion-panel>
    <mat-expansion-panel>
      <mat-expansion-panel-header>
        <mat-panel-title class="full-width" i18n>Default TLD</mat-panel-title>
      </mat-expansion-panel-header>
      <div layoutDirection="row" layoutDirection-xs="column" layoutDirection-sm="column">
        <div layoutDirection="column" appFlex="33" xsFlex="100" smFlex="100">
          <mat-checkbox formControlName="enable_default_tld" color="primary" i18n>Enable default TLD</mat-checkbox>
          <mat-form-field>
            <mat-label i18n>Default TLD</mat-label>
            <input matInput placeholder="Default TLD" i18n-placeholder
                   type="text" formControlName="default_tld" required>
            <mat-error>{{fieldErrors['default_tld']}}</mat-error>
          </mat-form-field>
        </div>
        <div layoutDirection="column" appFlex="66" xsFlex="100" smFlex="100">
          <div class="fl-help-text">
            <h3 i18n>Enable default TLD</h3>
            <p i18n>Default TLD will be used when client checks if a domain is available without specifying a TLD.</p>
          </div>
        </div>
      </div>
    </mat-expansion-panel>
    <mat-expansion-panel>
      <mat-expansion-panel-header>
        <mat-panel-title class="full-width" i18n>
          Default nameservers
        </mat-panel-title>
      </mat-expansion-panel-header>
      <div layoutDirection="row" layoutDirection-xs="column" layoutDirection-sm="column">
        <div layoutDirection="column" appFlex="33" xsFlex="100" smFlex="100">
          <mat-checkbox formControlName="enable_default_nameservers" color="primary" i18n>Enable default nameservers</mat-checkbox>
          <mat-form-field>
            <mat-label i18n>Default nameserver 1</mat-label>
            <input matInput placeholder="Default nameserver 1" i18n-placeholder
                   type="text" formControlName="default_nameserver1"
                   required>
            <mat-error>{{fieldErrors['default_nameserver1']}}</mat-error>
          </mat-form-field>
          <mat-form-field>
            <mat-label i18n>Default nameserver 2</mat-label>
            <input matInput placeholder="Default nameserver 2" i18n-placeholder
                   type="text" formControlName="default_nameserver2">
            <mat-error>{{fieldErrors['default_nameserver2']}}</mat-error>
          </mat-form-field>
          <mat-form-field>
            <mat-label i18n>Default nameserver 3</mat-label>
            <input matInput placeholder="Default nameserver 3" i18n-placeholder
                   type="text" formControlName="default_nameserver3">
            <mat-error>{{fieldErrors['default_nameserver3']}}</mat-error>
          </mat-form-field>
          <mat-form-field>
            <mat-label i18n>Default nameserver 4</mat-label>
            <input matInput placeholder="Default nameserver 4" i18n-placeholder
                   type="text" formControlName="default_nameserver4">
            <mat-error>{{fieldErrors['default_nameserver4']}}</mat-error>
          </mat-form-field>
        </div>
        <div layoutDirection="column" appFlex="66" xsFlex="100" smFlex="100">
          <div class="fl-help-text">
            <h3 i18n>Enable default nameservers</h3>
            <p i18n>Default nameservers will be used when client orders a domain without specifying nameservers.</p>
          </div>
        </div>
      </div>
    </mat-expansion-panel>

    <mat-expansion-panel>
      <mat-expansion-panel-header>
        <mat-panel-title class="full-width" i18n>Domain notifications</mat-panel-title>
      </mat-expansion-panel-header>
      <div layoutDirection="row" layoutDirection-xs="column" layoutDirection-sm="column">
        <div layoutDirection="column" appFlex="45" xsFlex="100" smFlex="100">
          <mat-checkbox formControlName="domain_notifications_enabled" color="primary" i18n>Enable domain notifications</mat-checkbox>
          <p i18n>Domain renewal notifications</p>
          <div layoutDirection="row">
            <mat-form-field subscriptSizing="dynamic" appFlex="33" class="fl-margin-right-small">
              <mat-label i18n>Hours remaining</mat-label>
              <input matInput placeholder="Hours remaining" i18n-placeholder type="number"
                     formControlName="first_domain_renewal_reminder_remaining_hours" required>
              <mat-error>{{fieldErrors['first_domain_renewal_reminder_remaining_hours']}}</mat-error>
            </mat-form-field>
            <mat-form-field appFlex="66">
              <mat-label i18n>Message template</mat-label>
              <mat-select formControlName="first_domain_renewal_reminder_notification_template"
                          placeholder="Message template" i18n-placeholder>
                <mat-option [value]="''" i18n>do not send</mat-option>
                <ng-container *ngIf="domainsConfiguration">
                  <mat-option *ngFor="let notification of domainsConfiguration.domain_message_templates"
                              [value]="notification[0]">
                    {{notification[0]}}
                  </mat-option>
                </ng-container>
              </mat-select>
            </mat-form-field>
          </div>
          <div layoutDirection="row">
            <mat-form-field subscriptSizing="dynamic" appFlex="33" class="fl-margin-right-small">
              <mat-label i18n>Hours remaining</mat-label>
              <input matInput placeholder="Hours remaining" i18n-placeholder type="number"
                     formControlName="second_domain_renewal_reminder_remaining_hours" required>
              <mat-error>{{fieldErrors['second_domain_renewal_reminder_remaining_hours']}}</mat-error>
            </mat-form-field>
            <mat-form-field appFlex="66">
              <mat-label i18n>Message template</mat-label>
              <mat-select formControlName="second_domain_renewal_reminder_notification_template"
                          placeholder="Message template" i18n-placeholder>
                <mat-option [value]="''" i18n>do not send</mat-option>
                <ng-container *ngIf="domainsConfiguration">
                  <mat-option *ngFor="let notification of domainsConfiguration.domain_message_templates"
                              [value]="notification[0]">
                    {{notification[0]}}
                  </mat-option>
                </ng-container>
              </mat-select>
            </mat-form-field>
          </div>
          <div layoutDirection="row">
            <mat-form-field subscriptSizing="dynamic" appFlex="33" class="fl-margin-right-small">
              <mat-label i18n>Hours remaining</mat-label>
              <input matInput placeholder="Hours remaining" i18n-placeholder type="number"
                     formControlName="third_domain_renewal_reminder_remaining_hours" required>
              <mat-error>{{fieldErrors['third_domain_renewal_reminder_remaining_hours']}}</mat-error>
            </mat-form-field>
            <mat-form-field appFlex="66">
              <mat-label i18n>Message template</mat-label>
              <mat-select formControlName="third_domain_renewal_reminder_notification_template"
                          placeholder="Message template" i18n-placeholder>
                <mat-option [value]="''" i18n>do not send</mat-option>
                <ng-container *ngIf="domainsConfiguration">
                  <mat-option *ngFor="let notification of domainsConfiguration.domain_message_templates"
                              [value]="notification[0]">
                    {{notification[0]}}
                  </mat-option>
                </ng-container>
              </mat-select>
            </mat-form-field>
          </div>
          <div layoutDirection="row">
            <mat-form-field subscriptSizing="dynamic" appFlex="33" class="fl-margin-right-small">
              <mat-label i18n>Hours remaining</mat-label>
              <input matInput placeholder="Hours remaining" i18n-placeholder type="number"
                     formControlName="fourth_domain_renewal_reminder_remaining_hours" required>
              <mat-error>{{fieldErrors['fourth_domain_renewal_reminder_remaining_hours']}}</mat-error>
            </mat-form-field>
            <mat-form-field appFlex="66">
              <mat-label i18n>Message template</mat-label>
              <mat-select formControlName="fourth_domain_renewal_reminder_notification_template"
                          placeholder="Message template" i18n-placeholder>
                <mat-option [value]="''" i18n>do not send</mat-option>
                <ng-container *ngIf="domainsConfiguration">
                  <mat-option *ngFor="let notification of domainsConfiguration.domain_message_templates"
                              [value]="notification[0]">
                    {{notification[0]}}
                  </mat-option>
                </ng-container>
              </mat-select>
            </mat-form-field>
          </div>
          <div layoutDirection="row">
            <mat-form-field subscriptSizing="dynamic" appFlex="33" class="fl-margin-right-small">
              <mat-label i18n>Hours remaining</mat-label>
              <input matInput placeholder="Hours remaining" i18n-placeholder type="number"
                     formControlName="fifth_domain_renewal_reminder_remaining_hours" required>
              <mat-error>{{fieldErrors['fifth_domain_renewal_reminder_remaining_hours']}}</mat-error>
            </mat-form-field>
            <mat-form-field appFlex="66">
              <mat-label i18n>Message template</mat-label>
              <mat-select formControlName="fifth_domain_renewal_reminder_notification_template"
                          placeholder="Message template" i18n-placeholder>
                <mat-option [value]="''" i18n>do not send</mat-option>
                <ng-container *ngIf="domainsConfiguration">
                  <mat-option *ngFor="let notification of domainsConfiguration.domain_message_templates"
                              [value]="notification[0]">
                    {{notification[0]}}
                  </mat-option>
                </ng-container>
              </mat-select>
            </mat-form-field>
          </div>

          <mat-form-field>
            <mat-label i18n>Domain registration confirmation message template</mat-label>
            <mat-select formControlName="domain_registration_confirmation_notification_template"
                        placeholder="Domain registration confirmation message template" i18n-placeholder>
              <mat-option [value]="''" i18n>do not send</mat-option>
              <ng-container *ngIf="domainsConfiguration">
                <mat-option *ngFor="let notification of domainsConfiguration.domain_message_templates"
                            [value]="notification[0]">
                  {{notification[0]}}
                </mat-option>
              </ng-container>
            </mat-select>
          </mat-form-field>
          <mat-form-field>
            <mat-label i18n>Domain transfer initiated message template</mat-label>
            <mat-select formControlName="domain_transfer_initiated_notification_template"
                        placeholder="Domain transfer initiated message template" i18n-placeholder>
              <mat-option [value]="''" i18n>do not send</mat-option>
              <ng-container *ngIf="domainsConfiguration">
                <mat-option *ngFor="let notification of domainsConfiguration.domain_message_templates"
                            [value]="notification[0]">
                  {{notification[0]}}
                </mat-option>
              </ng-container>
            </mat-select>
          </mat-form-field>
          <mat-form-field>
            <mat-label i18n>Domain transfer completed message template</mat-label>
            <mat-select formControlName="domain_transfer_completed_notification_template"
                        placeholder="Domain transfer completed message template" i18n-placeholder>
              <mat-option [value]="''" i18n>do not send</mat-option>
              <ng-container *ngIf="domainsConfiguration">
                <mat-option *ngFor="let notification of domainsConfiguration.domain_message_templates"
                            [value]="notification[0]">
                  {{notification[0]}}
                </mat-option>
              </ng-container>
            </mat-select>
          </mat-form-field>
          <mat-form-field>
            <mat-label i18n>Domain transfer failed message template</mat-label>
            <mat-select formControlName="domain_transfer_failed_notification_template"
                        placeholder="Domain transfer failed message template" i18n-placeholder>
              <mat-option [value]="''" i18n>do not send</mat-option>
              <ng-container *ngIf="domainsConfiguration">
                <mat-option *ngFor="let notification of domainsConfiguration.domain_message_templates"
                            [value]="notification[0]">
                  {{notification[0]}}
                </mat-option>
              </ng-container>
            </mat-select>
          </mat-form-field>
          <mat-form-field>
            <mat-label i18n>Domain expired message template</mat-label>
            <mat-select formControlName="domain_expired_notification_template"
                        placeholder="Domain expired message template" i18n-placeholder>
              <mat-option [value]="''" i18n>do not send</mat-option>
              <ng-container *ngIf="domainsConfiguration">
                <mat-option *ngFor="let notification of domainsConfiguration.domain_message_templates"
                            [value]="notification[0]">
                  {{notification[0]}}
                </mat-option>
              </ng-container>
            </mat-select>
          </mat-form-field>
        </div>
        <div layoutDirection="column" appFlex="55" xsFlex="100" smFlex="100">
          <div class="fl-help-text">
            <h3 i18n>Enable domain notification</h3>
            <p i18n>Send domain related notifications
              (renewal reminders, payment overdue reminders, registration confirmation, transfer and expiration)</p>
            <h3 i18n>Domain renewal reminder notifications</h3>
            <p i18n>Select how many hours until the domain expires and a message template to send.</p>
            <h3 i18n>Domain registration confirmation message template</h3>
            <p i18n>Select a message template to send.</p>
            <h3 i18n>Domain transfer initiated message template</h3>
            <p i18n>Select a message template to send.</p>
            <h3 i18n>Domain transfer completed message template</h3>
            <p i18n>Select a message template to send.</p>
            <h3 i18n>Domain transfer failed message template</h3>
            <p i18n>Select a message template to send.</p>
            <h3 i18n>Domain expired message template</h3>
            <p i18n>Select a message template to send.</p>
          </div>
        </div>
      </div>
    </mat-expansion-panel>

  </mat-accordion>
</form>
