import { Component, ViewEncapsulation } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ReactiveFormsModule } from '@angular/forms';
import { MultiSelectModule } from 'primeng/multiselect';
import { TranslationHelper } from '../../../utils/translation.helper';
import { DynamicFieldWrapperComponent } from './dynamic-field-wrapper.component';
import { DynamicFieldBaseComponent } from './dynamic-field-base.component';
import * as i0 from "@angular/core";
import * as i1 from "../../../services/translation.service";
import * as i2 from "@angular/forms";
import * as i3 from "primeng/multiselect";
export class DynamicFieldMultiselectComponent extends DynamicFieldBaseComponent {
    constructor(translationService) {
        super(translationService);
    }
    getPlaceholder() {
        if (this.mode === 'filter') {
            return TranslationHelper.translate(this.translationService, 'filter_select_placeholder', { label: this.field.label.toLowerCase() });
        }
        return this.field.placeholder || TranslationHelper.translate(this.translationService, 'select_option');
    }
    getOptions() {
        if (this.field.enumValues) {
            return this.field.enumValues.map(value => ({
                label: this.field.enumLabels?.[value] || value,
                value: value
            }));
        }
        if (this.field.enumOptions) {
            return this.field.enumOptions;
        }
        return this.field.options || [];
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DynamicFieldMultiselectComponent, deps: [{ token: i1.TranslationService }], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: DynamicFieldMultiselectComponent, isStandalone: true, selector: "sia-dynamic-field-multiselect", usesInheritance: true, ngImport: i0, template: `
    <sia-dynamic-field-wrapper [field]="field" [form]="form" [mode]="mode">
      <div [formGroup]="form">
        <p-multiSelect
          [inputId]="field.field"
          [formControlName]="field.field"
          [options]="getOptions()"
          [optionLabel]="field.optionLabel || 'label'"
          [optionValue]="field.optionValue || 'value'"
          [placeholder]="getPlaceholder()"
          [showClear]="mode === 'filter' || field.showClear"
          [filter]="field.filter || false"
          [filterBy]="field.filterBy"
          [maxSelectedLabels]="field.maxSelectedLabels ?? 3"
          [class.ng-invalid]="isFieldInvalid()"
          [class.ng-dirty]="isFieldDirty()"
          [appendTo]="'body'"
          panelStyleClass="dynamic-form-multiselect-panel"
          styleClass="w-full">
        </p-multiSelect>
      </div>
    </sia-dynamic-field-wrapper>
  `, isInline: true, styles: ["::ng-deep p-multiselect,::ng-deep p-multiSelect{width:100%;.p-multiselect{width:100%}}.dynamic-form-multiselect-panel{min-width:100%!important}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: MultiSelectModule }, { kind: "component", type: i3.MultiSelect, selector: "p-multiSelect, p-multiselect, p-multi-select", inputs: ["id", "ariaLabel", "style", "styleClass", "panelStyle", "panelStyleClass", "inputId", "disabled", "fluid", "readonly", "group", "filter", "filterPlaceHolder", "filterLocale", "overlayVisible", "tabindex", "variant", "appendTo", "dataKey", "name", "ariaLabelledBy", "displaySelectedLabel", "maxSelectedLabels", "selectionLimit", "selectedItemsLabel", "showToggleAll", "emptyFilterMessage", "emptyMessage", "resetFilterOnHide", "dropdownIcon", "chipIcon", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "showHeader", "filterBy", "scrollHeight", "lazy", "virtualScroll", "loading", "virtualScrollItemSize", "loadingIcon", "virtualScrollOptions", "overlayOptions", "ariaFilterLabel", "filterMatchMode", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "autofocusFilter", "display", "autocomplete", "size", "showClear", "autofocus", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "defaultLabel", "placeholder", "options", "filterValue", "itemSize", "selectAll", "focusOnHover", "filterFields", "selectOnFocus", "autoOptionFocus"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onClear", "onPanelShow", "onPanelHide", "onLazyLoad", "onRemove", "onSelectAllChange"] }, { kind: "component", type: DynamicFieldWrapperComponent, selector: "sia-dynamic-field-wrapper", inputs: ["field", "form", "mode"] }], encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DynamicFieldMultiselectComponent, decorators: [{
            type: Component,
            args: [{ selector: 'sia-dynamic-field-multiselect', standalone: true, imports: [
                        CommonModule,
                        ReactiveFormsModule,
                        MultiSelectModule,
                        DynamicFieldWrapperComponent
                    ], template: `
    <sia-dynamic-field-wrapper [field]="field" [form]="form" [mode]="mode">
      <div [formGroup]="form">
        <p-multiSelect
          [inputId]="field.field"
          [formControlName]="field.field"
          [options]="getOptions()"
          [optionLabel]="field.optionLabel || 'label'"
          [optionValue]="field.optionValue || 'value'"
          [placeholder]="getPlaceholder()"
          [showClear]="mode === 'filter' || field.showClear"
          [filter]="field.filter || false"
          [filterBy]="field.filterBy"
          [maxSelectedLabels]="field.maxSelectedLabels ?? 3"
          [class.ng-invalid]="isFieldInvalid()"
          [class.ng-dirty]="isFieldDirty()"
          [appendTo]="'body'"
          panelStyleClass="dynamic-form-multiselect-panel"
          styleClass="w-full">
        </p-multiSelect>
      </div>
    </sia-dynamic-field-wrapper>
  `, encapsulation: ViewEncapsulation.None, styles: ["::ng-deep p-multiselect,::ng-deep p-multiSelect{width:100%;.p-multiselect{width:100%}}.dynamic-form-multiselect-panel{min-width:100%!important}\n"] }]
        }], ctorParameters: () => [{ type: i1.TranslationService }] });
//# sourceMappingURL=data:application/json;base64, 