/*!
 * Copyright 2020 VMware, Inc.
 * SPDX-License-Identifier: BSD-2-Clause
 */
import { Component } from '@angular/core';
import { FieldType } from '@ngx-formly/core';
import { Observable, of } from 'rxjs';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "../../../../form/form-select/form-select.component";
import * as i3 from "@angular/common";
export class FormlySelectComponent extends FieldType {
    get errorLabels() {
        return this.to.errorLabels || [];
    }
    get selectOptions() {
        if (!(this.to.options instanceof Observable)) {
            return of(this.to.options);
        }
        return this.to.options;
    }
}
/** @nocollapse */ FormlySelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: FormlySelectComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
/** @nocollapse */ FormlySelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.4", type: FormlySelectComponent, selector: "vcd-formly-select", usesInheritance: true, ngImport: i0, template: `
        <vcd-form-select
            [label]="to.label"
            [description]="to.description"
            [showAsterisk]="to.required"
            [isReadOnly]="to.isReadOnly"
            [errorLabels]="errorLabels"
            [formControl]="formControl"
            [options]="selectOptions | async"
        >
        </vcd-form-select>
    `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i2.FormSelectComponent, selector: "vcd-form-select", inputs: ["options", "hintPosition", "hint"] }, { kind: "pipe", type: i3.AsyncPipe, name: "async" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: FormlySelectComponent, decorators: [{
            type: Component,
            args: [{
                    selector: 'vcd-formly-select',
                    template: `
        <vcd-form-select
            [label]="to.label"
            [description]="to.description"
            [showAsterisk]="to.required"
            [isReadOnly]="to.isReadOnly"
            [errorLabels]="errorLabels"
            [formControl]="formControl"
            [options]="selectOptions | async"
        >
        </vcd-form-select>
    `,
                }]
        }] });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9ybWx5LXNlbGVjdC5jb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9jb21wb25lbnRzL3NyYy9mb3JtbHkvdmNkL2lucHV0cy9zZWxlY3QvZm9ybWx5LXNlbGVjdC5jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7OztHQUdHO0FBRUgsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUMxQyxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDN0MsT0FBTyxFQUFFLFVBQVUsRUFBRSxFQUFFLEVBQUUsTUFBTSxNQUFNLENBQUM7Ozs7O0FBa0J0QyxNQUFNLE9BQU8scUJBQXNCLFNBQVEsU0FBUztJQUNoRCxJQUFJLFdBQVc7UUFDWCxPQUFPLElBQUksQ0FBQyxFQUFFLENBQUMsV0FBVyxJQUFJLEVBQUUsQ0FBQztJQUNyQyxDQUFDO0lBRUQsSUFBSSxhQUFhO1FBQ2IsSUFBSSxDQUFDLENBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxPQUFPLFlBQVksVUFBVSxDQUFDLEVBQUU7WUFDMUMsT0FBTyxFQUFFLENBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxPQUFPLENBQUMsQ0FBQztTQUM5QjtRQUNELE9BQU8sSUFBSSxDQUFDLEVBQUUsQ0FBQyxPQUFPLENBQUM7SUFDM0IsQ0FBQzs7cUlBVlEscUJBQXFCO3lIQUFyQixxQkFBcUIsZ0ZBYnBCOzs7Ozs7Ozs7OztLQVdUOzJGQUVRLHFCQUFxQjtrQk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