<!--

    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 class="tb-widget-settings flex flex-col" [formGroup]="navigationCardsWidgetSettingsForm">
  <section style="margin-bottom: 16px;">
    <div class="mat-caption" style="margin: -8px 0 8px;" translate>widgets.navigation.filter-type</div>
    <mat-radio-group formControlName="filterType" class="gap-4">
      <mat-radio-button [value]="'all'">{{ 'widgets.navigation.filter-type-all' | translate }}</mat-radio-button>
      <mat-radio-button [value]="'include'">{{ 'widgets.navigation.filter-type-include' | translate }}</mat-radio-button>
      <mat-radio-button [value]="'exclude'">{{ 'widgets.navigation.filter-type-exclude' | translate }}</mat-radio-button>
    </mat-radio-group>
  </section>
  <mat-form-field [class.!hidden]="navigationCardsWidgetSettingsForm.get('filterType').value === 'all'" class="mat-block flex-1" floatLabel="always" appearance="outline">
    <mat-label translate>widgets.navigation.items</mat-label>
    <mat-chip-grid #filterItemsChipList>
      @for (filterItem of navigationCardsWidgetSettingsForm.get('filter').value; track filterItem) {
        <mat-chip-row
          [removable]="true" (removed)="onFilterItemRemoved(filterItem)">
          {{ filterItem }}
          <mat-icon matChipRemove>cancel</mat-icon>
        </mat-chip-row>
      }
      <input matInput type="text" placeholder="{{ 'widgets.navigation.enter-urls-to-filter' | translate }}"
             style="max-width: 200px;"
             #filterItemInput
             (focusin)="onFilterItemInputFocus()"
             matAutocompleteOrigin
             #origin="matAutocompleteOrigin"
             (input)="filterItemInputChange.next(filterItemInput.value)"
             [matAutocompleteConnectedTo]="origin"
             [matAutocomplete]="filterItemAutocomplete"
             [matChipInputFor]="filterItemsChipList"
             [matChipInputSeparatorKeyCodes]="separatorKeysCodes"
             (matChipInputTokenEnd)="addFilterItemFromChipInput($event)">
    </mat-chip-grid>
    <mat-autocomplete #filterItemAutocomplete="matAutocomplete"
                      class="tb-autocomplete"
                      (optionSelected)="filterItemSelected($event)">
      @for (filterItem of filteredFilterItems | async; track filterItem) {
        <mat-option [value]="filterItem">
          <span [innerHTML]="filterItem | highlight:filterItemSearchText"></span>
        </mat-option>
      }
    </mat-autocomplete>
  </mat-form-field>
</section>
