import { Component, Input, ElementRef, ViewChild, HostListener } from '@angular/core';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "../al-form-group/al-form-group.component";
import * as i3 from "../al-icon/al-icon.component";
const _c0 = ["customButtonContent"];
function AlDropdownComponent_ng_container_4_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
function AlDropdownComponent_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, AlDropdownComponent_ng_container_4_ng_container_1_Template, 1, 0, "ng-container", 5);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    i0.ɵɵnextContext();
    const _r3 = i0.ɵɵreference(7);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", _r3);
} }
function AlDropdownComponent_ng_container_5_ng_container_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
const _c1 = function (a0) { return [a0]; };
function AlDropdownComponent_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    const _r8 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "al2-form-group", 6);
    i0.ɵɵelementStart(2, "div", 7);
    i0.ɵɵelementStart(3, "button", 8);
    i0.ɵɵlistener("click", function AlDropdownComponent_ng_container_5_Template_button_click_3_listener() { i0.ɵɵrestoreView(_r8); const ctx_r7 = i0.ɵɵnextContext(); return ctx_r7.optionsVisible = !ctx_r7.optionsVisible; });
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "div", 9);
    i0.ɵɵelement(6, "al2-icon", 10);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(7, AlDropdownComponent_ng_container_5_ng_container_7_Template, 1, 0, "ng-container", 5);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext();
    const _r3 = i0.ɵɵreference(7);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("id", ctx_r2.id)("label", ctx_r2.label)("tip", ctx_r2.tip)("hint", ctx_r2.hint)("required", ctx_r2.required);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(9, _c1, ctx_r2.disabled ? "ald-select__element--disabled" : ""));
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r2.buttonText, " ");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(11, _c1, ctx_r2.disabled ? "ald-select__icon--disabled" : ""));
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngTemplateOutlet", _r3);
} }
function AlDropdownComponent_ng_template_6_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 12);
    i0.ɵɵprojection(1, 1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r9 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(1, _c1, ctx_r9.customButton ? "w-80" : "w-full"));
} }
function AlDropdownComponent_ng_template_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtemplate(0, AlDropdownComponent_ng_template_6_div_0_Template, 2, 3, "div", 11);
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngIf", ctx_r4.optionsVisible);
} }
const _c2 = [[["", "dropdown", ""]], "*"];
const _c3 = ["[dropdown]", "*"];
export class AlDropdownComponent {
    constructor(eref) {
        this.eref = eref;
        this.label = '';
        this.buttonText = 'Select Options';
        this.verticalSpace = true;
        this.disabled = false;
        this.customButton = false;
        this.optionsVisible = false;
    }
    clickOut(event) {
        if (!this.eref.nativeElement.contains(event.target)) {
            this.close();
        }
    }
    ngOnInit() {
        var _a;
        this.customButton = !!((_a = this.customButtonContent) === null || _a === void 0 ? void 0 : _a.nativeElement.innerHTML);
    }
    close() {
        this.optionsVisible = false;
    }
}
/** @nocollapse */ AlDropdownComponent.ɵfac = function AlDropdownComponent_Factory(t) { return new (t || AlDropdownComponent)(i0.ɵɵdirectiveInject(i0.ElementRef)); };
/** @nocollapse */ AlDropdownComponent.ɵcmp = i0.ɵɵdefineComponent({ type: AlDropdownComponent, selectors: [["al2-dropdown"]], viewQuery: function AlDropdownComponent_Query(rf, ctx) { if (rf & 1) {
        i0.ɵɵstaticViewQuery(_c0, true, ElementRef);
    } if (rf & 2) {
        var _t;
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.customButtonContent = _t.first);
    } }, hostBindings: function AlDropdownComponent_HostBindings(rf, ctx) { if (rf & 1) {
        i0.ɵɵlistener("click", function AlDropdownComponent_click_HostBindingHandler($event) { return ctx.clickOut($event); }, false, i0.ɵɵresolveDocument);
    } }, inputs: { id: "id", label: "label", buttonText: "buttonText", verticalSpace: "verticalSpace", hint: "hint", tip: "tip", disabled: "disabled", error: "error", required: "required" }, ngContentSelectors: _c3, decls: 8, vars: 2, consts: [[1, "ald-dropdown"], [3, "click"], ["customButtonContent", ""], [4, "ngIf"], ["dropdownContent", ""], [4, "ngTemplateOutlet"], [3, "id", "label", "tip", "hint", "required"], [1, "ald-select"], [1, "ald-select__element", "text-left", 3, "ngClass", "click"], [1, "ald-select__icon", 3, "ngClass"], ["icon", "keyboard_arrow_down"], ["class", "ald-dropdown__content", 3, "ngClass", 4, "ngIf"], [1, "ald-dropdown__content", 3, "ngClass"]], template: function AlDropdownComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵprojectionDef(_c2);
        i0.ɵɵelementStart(0, "div", 0);
        i0.ɵɵelementStart(1, "div", 1, 2);
        i0.ɵɵlistener("click", function AlDropdownComponent_Template_div_click_1_listener() { return ctx.optionsVisible = !ctx.optionsVisible; });
        i0.ɵɵprojection(3);
        i0.ɵɵelementEnd();
        i0.ɵɵtemplate(4, AlDropdownComponent_ng_container_4_Template, 2, 1, "ng-container", 3);
        i0.ɵɵtemplate(5, AlDropdownComponent_ng_container_5_Template, 8, 13, "ng-container", 3);
        i0.ɵɵelementEnd();
        i0.ɵɵtemplate(6, AlDropdownComponent_ng_template_6_Template, 1, 1, "ng-template", null, 4, i0.ɵɵtemplateRefExtractor);
    } if (rf & 2) {
        i0.ɵɵadvance(4);
        i0.ɵɵproperty("ngIf", ctx.customButton);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", !ctx.customButton);
    } }, directives: [i1.NgIf, i1.NgTemplateOutlet, i2.AlFormGroupComponent, i1.NgClass, i3.AlIconComponent], encapsulation: 2 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(AlDropdownComponent, [{
        type: Component,
        args: [{
                selector: 'al2-dropdown',
                templateUrl: './al-dropdown.component.html',
                host: {
                    '(document:click)': 'clickOut($event)'
                }
            }]
    }], function () { return [{ type: i0.ElementRef }]; }, { customButtonContent: [{
            type: ViewChild,
            args: ['customButtonContent', { read: ElementRef, static: true }]
        }], id: [{
            type: Input
        }], label: [{
            type: Input
        }], buttonText: [{
            type: Input
        }], verticalSpace: [{
            type: Input
        }], hint: [{
            type: Input
        }], tip: [{
            type: Input
        }], disabled: [{
            type: Input
        }], error: [{
            type: Input
        }], required: [{
            type: Input
        }], clickOut: [{
            type: HostListener,
            args: ['document:click', ['$event']]
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 