<!--

    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" [formGroup]="tripAnimationMarkerSettingsFormGroup">
  <fieldset class="fields-group">
    <legend class="group-title" translate>widgets.maps.markers-settings</legend>
    <mat-form-field class="mat-block">
      <mat-label translate>widgets.maps.rotation-angle</mat-label>
      <input matInput type="number" min="0" max="360" formControlName="rotationAngle">
    </mat-form-field>
    <fieldset class="fields-group fields-group-slider">
      <legend class="group-title" translate>widgets.maps.label</legend>
      <mat-expansion-panel class="tb-settings" [expanded]="tripAnimationMarkerSettingsFormGroup.get('showLabel').value">
        <mat-expansion-panel-header class="flex-wrap">
          <mat-panel-title>
            <mat-slide-toggle formControlName="showLabel" (click)="$event.stopPropagation()">
              {{ 'widgets.maps.show-label' | translate }}
            </mat-slide-toggle>
          </mat-panel-title>
          <mat-panel-description class="justify-end xs:!hidden" translate>
            widget-config.advanced-settings
          </mat-panel-description>
        </mat-expansion-panel-header>
        <ng-template matExpansionPanelContent>
          <mat-slide-toggle formControlName="useLabelFunction" class="slide-block">
            {{ 'widgets.maps.use-label-function' | translate }}
          </mat-slide-toggle>
          <tb-html [class.!hidden]="tripAnimationMarkerSettingsFormGroup.get('useLabelFunction').value"
                   formControlName="label"
                   minHeight="100px"
                   label="{{ 'widgets.maps.label-pattern' | translate }}">
          </tb-html>
          <tb-js-func [class.!hidden]="!tripAnimationMarkerSettingsFormGroup.get('useLabelFunction').value"
                      formControlName="labelFunction"
                      withModules
                      [globalVariables]="functionScopeVariables"
                      [functionArgs]="['data', 'dsData', 'dsIndex']"
                      functionTitle="{{ 'widgets.maps.label-function' | translate }}"
                      helpId="widget/lib/map-legacy/label_fn">
          </tb-js-func>
        </ng-template>
      </mat-expansion-panel>
    </fieldset>
    <fieldset class="fields-group fields-group-slider">
      <legend class="group-title" translate>widgets.maps.marker-image</legend>
      <mat-expansion-panel class="tb-settings" expanded>
        <mat-expansion-panel-header class="flex-wrap">
          <mat-panel-title>
            <mat-slide-toggle formControlName="useMarkerImageFunction" (click)="$event.stopPropagation()">
              {{ 'widgets.maps.use-marker-image-function' | translate }}
            </mat-slide-toggle>
          </mat-panel-title>
          <mat-panel-description class="justify-end xs:!hidden" translate>
            widget-config.advanced-settings
          </mat-panel-description>
        </mat-expansion-panel-header>
        <ng-template matExpansionPanelContent>
          <tb-gallery-image-input [class.!hidden]="tripAnimationMarkerSettingsFormGroup.get('useMarkerImageFunction').value"
                          label="{{ 'widgets.maps.custom-marker-image' | translate }}"
                          formControlName="markerImage">
          </tb-gallery-image-input>
          <mat-form-field [class.!hidden]="tripAnimationMarkerSettingsFormGroup.get('useMarkerImageFunction').value"
                          class="mat-block">
            <mat-label translate>widgets.maps.custom-marker-image-size</mat-label>
            <input matInput type="number" min="1" formControlName="markerImageSize">
          </mat-form-field>
          <tb-js-func [class.!hidden]="!tripAnimationMarkerSettingsFormGroup.get('useMarkerImageFunction').value"
                      withModules
                      formControlName="markerImageFunction"
                      [globalVariables]="functionScopeVariables"
                      [functionArgs]="['data', 'images', 'dsData', 'dsIndex']"
                      functionTitle="{{ 'widgets.maps.marker-image-function' | translate }}"
                      helpId="widget/lib/map-legacy/marker_image_fn">
          </tb-js-func>
          <tb-multiple-gallery-image-input [class.!hidden]="!tripAnimationMarkerSettingsFormGroup.get('useMarkerImageFunction').value"
                                           label="{{ 'widgets.maps.marker-images' | translate }}"
                                           formControlName="markerImages">
          </tb-multiple-gallery-image-input>
        </ng-template>
      </mat-expansion-panel>
    </fieldset>
  </fieldset>
</section>
