import { Component, ViewEncapsulation } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ReactiveFormsModule } from '@angular/forms';
import { DropdownModule } from 'primeng/dropdown';
import { DynamicFieldWrapperComponent } from './dynamic-field-wrapper.component';
import { DynamicFieldBaseComponent } from './dynamic-field-base.component';
import { TranslationHelper } from '../../../utils/translation.helper';
import * as i0 from "@angular/core";
import * as i1 from "../../../services/translation.service";
import * as i2 from "@angular/forms";
import * as i3 from "primeng/dropdown";
export class DynamicFieldDropdownComponent extends DynamicFieldBaseComponent {
    constructor(translationService) {
        super(translationService);
    }
    // Override customizado para dropdown
    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.type === 'enum' && this.field.enumValues) {
            return this.field.enumValues.map(value => ({
                label: this.field.enumLabels?.[value] || value,
                value: value
            }));
        }
        if (this.field.type === 'enum' && 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: DynamicFieldDropdownComponent, deps: [{ token: i1.TranslationService }], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: DynamicFieldDropdownComponent, isStandalone: true, selector: "sia-dynamic-field-dropdown", usesInheritance: true, ngImport: i0, template: `
    <sia-dynamic-field-wrapper [field]="field" [form]="form" [mode]="mode">
      <div [formGroup]="form">
        <p-dropdown
          [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"
          [class.ng-invalid]="isFieldInvalid()"
          [class.ng-dirty]="isFieldDirty()"
          [appendTo]="'body'"
          panelStyleClass="dynamic-form-dropdown-panel"
          styleClass="w-full"
          [style]="{width: '100%'}">
        </p-dropdown>
      </div>
    </sia-dynamic-field-wrapper>
  `, isInline: true, styles: ["::ng-deep p-dropdown{width:100%;.p-dropdown{width:100%}}.dynamic-form-dropdown-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: DropdownModule }, { kind: "component", type: i3.Dropdown, selector: "p-dropdown", inputs: ["id", "scrollHeight", "filter", "name", "style", "panelStyle", "styleClass", "panelStyleClass", "readonly", "required", "editable", "appendTo", "tabindex", "placeholder", "loadingIcon", "filterPlaceholder", "filterLocale", "variant", "inputId", "dataKey", "filterBy", "filterFields", "autofocus", "resetFilterOnHide", "checkmark", "dropdownIcon", "loading", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "autoDisplayFirst", "group", "showClear", "emptyFilterMessage", "emptyMessage", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "overlayOptions", "ariaFilterLabel", "ariaLabel", "ariaLabelledBy", "filterMatchMode", "maxlength", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "focusOnHover", "selectOnFocus", "autoOptionFocus", "autofocusFilter", "fluid", "disabled", "itemSize", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "filterValue", "options"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide", "onClear", "onLazyLoad"] }, { 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: DynamicFieldDropdownComponent, decorators: [{
            type: Component,
            args: [{ selector: 'sia-dynamic-field-dropdown', standalone: true, imports: [
                        CommonModule,
                        ReactiveFormsModule,
                        DropdownModule,
                        DynamicFieldWrapperComponent
                    ], template: `
    <sia-dynamic-field-wrapper [field]="field" [form]="form" [mode]="mode">
      <div [formGroup]="form">
        <p-dropdown
          [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"
          [class.ng-invalid]="isFieldInvalid()"
          [class.ng-dirty]="isFieldDirty()"
          [appendTo]="'body'"
          panelStyleClass="dynamic-form-dropdown-panel"
          styleClass="w-full"
          [style]="{width: '100%'}">
        </p-dropdown>
      </div>
    </sia-dynamic-field-wrapper>
  `, encapsulation: ViewEncapsulation.None, styles: ["::ng-deep p-dropdown{width:100%;.p-dropdown{width:100%}}.dynamic-form-dropdown-panel{min-width:100%!important}\n"] }]
        }], ctorParameters: () => [{ type: i1.TranslationService }] });
//# sourceMappingURL=data:application/json;base64, 